Interviews - C# Corner

Rahul Chavan
Write a code in such a way that my SQL connection should be always connected?
By Rahul Chavan in Databases & DBA onApr 07 2016
  • Rahul Chavan
    Apr, 2016 7

    connection.ConnectionTimeout=0; Setting timeout value as 0 will change defialt timeout to infinite.

    • 2
  • Sanjit Kumar Singh
    May, 2018 5

    var mysqltest = require('mysql'); var pool = mysqltest.createPool({host : ‘host.org',user : 'username',password : 'password' });exports.getUsers = function(callback) {pool.getConnection(function(err, connection) {if(err) { console.log(err); callback(true); return; }var sqlQuery = "SELECT id,name FROM users";connection.query(sqlQuery, [], function(err, results) {connection.release(); // always put connection back in pool after last queryif(err) { console.log(err); callback(true); return; }callback(false, results);});}); });

    • 0

Most Popular Companies

Most Popular Job Functions

MOST LIKED QUESTIONS