ConnectionError: Failed to connect to localhost:3306 - Cannot call write after a stream was destroyed in node.js i am getting error while running

Viewed 1223

In node.js I am getting error while running index.js file:

var dbConfig = {  
        user: "test",  
        password: "***",  
        server: "localhost",  
        database: "hello",
        port: parseInt("3306"),
        options: {
              "enableArithAbort": true
            }
}; 
app.get("/CodList", function(_req ,_res){  
    var Sqlquery = "select * from CodeList";  
    QueryToExecuteInDatabase(_res, Sqlquery);  
});  

How to fetch the records from dtabase using node.js?

1 Answers

I found this way to solve this problem :

    options: {
      encrypt:false
    }
    full :
    const msSqlConfig={
      server:SQL_SERVER_NAME,
      port:SQL_PORT,
      user:${SQL_USER_NAME},
      password:${SQL_PASSWORD},
      database:SQL_DB_NAME,
      options: {
          encrypt:false
      }
    }
Related