1

I cannot understand why could I connect to Mysql after release.

And is there a way to check the status of Mysql ?

Thanks for the help !

var mysqlConfig = {
    host     : "abcd",
    port     : "3306",
    user     : "root",
    password : "root",
    database : "test"
};
var pool = mysql.createPool(mysqlConfig);


pool.getConnection(function(err, conn) {
    // release pool
    conn.release();

    // After release, Why could I connect to Mysql ????
    conn.query('SELECT * FROM user_info WHERE user_id = ?', [id], function(err, rows) {
        if (err) {
            pushErr();
        }
        // ...
    });
});

1 Answer 1

1

Based on the documentation here: https://github.com/felixge/node-mysql it looks like the connection being 'released' doesn't destroy the connection per se, it just signals the pool that it can be used by someone else if needed. If you notice the example, they release as part of the query callback. If you need to actually get rid of the connection, you should use conn.destroy().

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.