I need to create a connection to an Oracle database with the Tedious library in node js. When i run the file this is what it return ' ConnectionError: Connection lost - socket hang up ', I don't know if this is useful information but I noticed that the SID parameter is set in the settings. Let me know if you need anything else. Thank you all.
This is my code:
const fs = require('fs');
const path = require('path');
const Connection = require('tedious').Connection;
let credsDb = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'creds_db_cmo.json')).toString());
var config = {
server: credsDb.server,
authentication: {
type: 'default',
options: {
userName: credsDb.user,
password: credsDb.password
}
},
options: {
port: 1521,
encrypt: false,
database: credsDb.database,
trustServerCertificate: true,
}
}
var connectionDB = new Connection(config);
connectionDB.on('connect', function (err) {
if (err) {
console.log('Error: ' + err);
} else {
console.log('DB Connected');
}
});
connectionDB.connect();
the creds_db_cmo.json is:
{ "user" : "user", "password": "password", "server": "server", "database": "database" }