Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var connect = function(){
- return new q(function(resolve, reject) {
- var sqlCon = mysql.createConnection(connectionObject);
- console.log("connecting");
- sqlCon.connect(function(err) {
- if(err && err.fatal && err.code == "PROTOCOL_CONNECTION_LOST"){
- return reject(false);
- }
- return resolve(true);
- });
- });
- };
- var connectRecursive = function(){
- return connect().then(function(connected){
- if(connected)
- {
- return connected;
- }
- else
- {
- return connectRecursive();
- }
- })
- };
- connectRecursive().then(function(res){
- console.log(res);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement