节点Mysql池未结束/关闭

时间:2014-12-09 18:30:22

标签: node.js node-mysql

我在这里遗漏了什么吗?这应该可以正常工作,但我发现Node run loop保持活动状态。

var mysql   = require('mysql');

//Setup Connections and Parser
var pool = mysql.createPool({
    host     : 'localhost',
    user     : 'me',
    password : '12345',
    database : 'A2014',
    connectionLimit: 100
});

pool.getConnection(function(err, connection) {

    connection.query( 'select count(9) from mytbl;', function(err, rows) {
        connection.release();
    });

});

pool.end();

1 个答案:

答案 0 :(得分:2)

var mysql   = require('mysql');

//Setup Connections and Parser
var pool = mysql.createPool({
    host     : 'localhost',
    user     : 'me',
    password : '12345',
    database : 'A2014',
    connectionLimit: 100
});

pool.getConnection(function(err, connection) {

    connection.query( 'select count(9) from mytbl;', function(err, rows) {
        connection.release();
    });
    pool.end();
});