Cannot enqueue Handshake after invoking quit

前端 未结 10 2294
小鲜肉
小鲜肉 2020-11-28 02:59

I have implemented the following code:

module.exports = {
    getDataFromUserGps: function(callback)
    {
        connection.connect();
        connection.qu         


        
10条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-28 03:58

    I had the same problem and Google led me here. I agree with @Ata that it's not right to just remove end(). After further Googling, I think using pooling is a better way.

    node-mysql doc about pooling

    It's like this:

    var mysql = require('mysql');
    var pool  = mysql.createPool(...);
    
    pool.getConnection(function(err, connection) {
        connection.query( 'bla bla', function(err, rows) {
            connection.release();
        });
    });
    

提交回复
热议问题