Node????mysql???????
???????????? ???????[ 2016/12/30 11:22:24 ] ????????????? Node
????4. ???1
????????????????????????????????????????????????? function ???????????
// connect.js ?????????????
var mysql = require('mysql');
var config = require('./config.json'); // ??????????????д??mysql??????config.mysql
var connCount = 0; // ?????δ????????
exports.getConn = function(){
connCount ++;
console.log('............................OPEN a connection?? has '+ connCount + ' connection.');
return mysql.createConnection(config.mysql);
};
exports.endConn = function(conn){
conn.end(function(err){
if(!err){
connCount --;
console.log('.........................CLOSE a connection?? has '+ connCount + ' connection.');
}
});
};
????????????????????????
// db.js ?????????
var connect = require('./connect.js'); // ???????????????
exports.getUser = function(username?? callback){
var connection = connect.getConn();
var sql = 'select * from user where username = "' + username + '"';
connection.query(sql??function(err??rows??fields){
callback(err??rows??fields);
});
connect.endConn(connection);
}
????5. ???2
??????????????????????????????????????????????????????
// connect.js ??????
var mysql = require('mysql');
var config = require('./config.json');
var pool = mysql.createPool(config.mysql);
exports.querySQL = function(sql??callback){
pool.query(sql?? function(err??rows??fields){
callback(err??rows??fields);
});
}
// connect.js ???getConnection????
var mysql = require('mysql');
var config = require('./config.json');
var pool = mysql.createPool(config.mysql);
exports.querySQL = function(sql?? callback){
pool.getConnection(function(err??conn){
conn.query(sql??function(err??rows??fields){
callback(err??rows??fields);
conn.release(); // ??????????
});
});
}
????????????????? querySQL ????????????£?
// db.js ?????????
var connect = require('./connect.js');
exports.getUser = function(username??callback){
var sql = 'select * from user where username = "' + username + '"';
connect.querySQL(sql??function(err??rows??fields){
callback(err??rows??fields);
});
};
?????????????????????????????????????????????? pool.query() ??????? pool.getConnection() ???????????????????н???????????????????????ò??????????????ж????????????о?????????????????л??~
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
???mysql?????????????mysql????? distinct?÷?MySQL?н???????????з??Mysql?????????MySQL Cluster??δ????????????????ν?MySQL??????????300???????MySQL???Uber???????????????????MySql SQL??????????MySQL?????????????????λЧ?????SQL???Java???????:?????MySQL???????linux?°??mysql????MySQL ???????????????????binlog??MySQL????????????Щ??????MySQL???????Mysql???????JDBC?????mysql?????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????