Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var pool = mysql.createPool({
- host: databaseHost,
- user: databaseUser,
- password: databasePassword,
- database: databaseName,
- multipleStatements: true
- });
- pool.getConnection(function (err, connection) {
- if (err) {
- callback(err);
- } else {
- // Use the connection
- var sql = "...sql statement...";
- var inserts = [...inserts...];
- connection.query(sql, inserts, function (error, results, fields) {
- // And done with the connection.
- connection.release();
- // Handle error after the release.
- if (error) {
- callback(error);
- } else {
- callback(null, results);
- }
- });
- }
- });
- "ER_CON_COUNT_ERROR: Too many connections"
- console.log(pool.config.connectionLimit); // passed in max size of the pool
- console.log(pool._freeConnections.length); // number of free connections awaiting use
- console.log(pool._allConnections.length); // number of connections currently created, including ones in use
- console.log(pool._acquiringConnections.length); // number of connections in the process of being acquired
- 10
- 0
- 0
- 0
Add Comment
Please, Sign In to add comment