我不知道为什么
mysql.end()或
mysql.destroy()不能像我期望的那样工作.这是我的代码.
var mysql = require('mysql');
var connection = mysql.createConnection({
host: 'localhost',
user: 'root',
database: 'db',
password: ''
});
connection.connect();
connection.query('SELECT * FROM ofertas ', function (err, rows, fields)
{
if (err) console.log(err);
else
{
console.log(rows);
}
});
connection.destroy(function (err)
{
if (err) throw err;
});
我执行此代码,然后我转到mysql命令行,我输入:
show status like 'Conn%';
在节点代码之前
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Connections | 3 |
+---------------+-------+
节点代码之后
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Connections | 4 |
+---------------+-------+
connection.state =’已断开’
谢谢