var mysql = require(‘mysql’); var pool = mysql.createPool(…);
pool.getConnection(function(err, connection) { // Use the connection connection.query( 'SELECT something FROM sometable’, function(err, rows) { // And done with the connection. connection.release();
// Don't use the connection here, it has been returned to the pool.
}); });
release只是单纯的将当前connection释放当pool中,否则如果请求的客户端多了,那数据库压力是不是很大?希望懂的人指点一下。