sql server - Create mssql connection pool in node.js application -
i refering node-mssql library application in node.js using mssql database connection. mssql-ref. have checked creation pool of connections, found same mysql , not mssql. please give reference can find sample code snippet mssql connection pool node.js. thanks.
you find information in page you're referring yourself. it's worth noting documenting not explicit how connection pool created.
var connection = new sql.connection(config);
the variable connection here connection pool still needs connect...
var connection = new sql.connection(config, function(err) { // ... error checks // query var request = new sql.request(connection); // or: var request = connection.request(); request.query('select 1 number', function(err, recordset) { // ... error checks console.dir(recordset); }); });
or using promises omitting callback argument
var connection = new sql.connection(config); //connection connection pool connection.connect().then(function() { var request = new sql.request(connection); request.query('select * mytable').then(function(recordset) { // ... }).catch(function(err) { // ... }); }).catch(function(err) { // ... });
after create single instance of connection, let requests use in example above opposed instantiating new connection object each request.
if asking in relation express 4 web application, see question , answers.
Comments
Post a Comment