Sunday 28 May 2017

How to make node.js mysql connection pooling available on startup

Every time my showData.js script is run it calls

var pool  = mysql.createPool({

Is there a way to create the connection pool on node.js server startup?

I've tried adding createPool to server.js but I can't seem to access the object from my showData.js script when I call

pool.getConnection(function(err,connection){

Is it even necessary to start the connection pool on node.js server startup? What I'm hoping is that when createPool is first called it creates a connection pool and stays alive for a while, even after

connection.release();

is called and the showData.js script closes.

Is this the case? Does the mysql connection pool stay 'open' even after the calling script closes?



via mcmacerson

No comments:

Post a Comment