I don't know why mysql.end() or mysql.destroy() are not working as i expect. This is my code.
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;
});
I execute this code and then i go to mysql command line and i type this :
show status like 'Conn%';
Before node code
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Connections | 3 |
+---------------+-------+
After node code
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Connections | 4 |
+---------------+-------+
connection.state = 'disconnected'
Thanks