title: Use single database connection in entire application?
body: <p>I am creating a application that will communicate over Udp protocol in node js. Also i am using sql server as a database so in order to connect this database i am using <code>mssql</code> npm liabrary. Basically what i am doing i have one separate module for dbcon as shown below <br></p>
  
  <pre><code>const sql = require('mssql')
  const config = {
      user: 'sa',
      password: '123',
      server: '192.168.1.164', // You can use 'localhost\\instance' to connect to named instance
      database: 'SBM-EMCURE',
  
      options: {
          encrypt: false // Use this if you're on Windows Azure
      }
  }
   sql.connect(config, err =&gt; {
  
   })
  
  sql.on('error', err =&gt; {
      console.log('error on sql.on()');
  })
  module.exports.sql = sql;
  </code></pre>
  
  <p>And i am using this exported sql object to run my queries outside dbcon module but it gives me different behavior sometimes like query executes before databse connection, is there is any way to use single database connection for entire application?. Using single database connection is useful or it will slow down my process<br>
  Thanks in advance</p>