Answer the question
In order to leave comments, you need to log in
How to create two connections to different sql server in node.js?
I create a connection in this way
var mssql = require('mssql');
var pool1 = mssql.connect(config1, err => {
console.log(err);
});
var pool2 = mssql.connect(config2, err => {
console.log(err);
});
To which I get the error Global connection already exists
It turns out it is impossible to create two connections at the same time, without closing the previous one
Answer the question
In order to leave comments, you need to log in
Figured it out myself. Instead of connect, you need to use ConnectionPool(config).connect(err => {}). Apparently connect creates a pool and sets it as global, and if the global pool is already set, it throws an exception.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question