This is the first time I work with javascript and node.js.
I have no idea what the error might be and how to make the connection, my problem initially came up here: link .
I have the following simple code that connects a node server to a database and makes a select only.
var express = require('express');
var app = express();
app.get('/', function (req, res) {
var sql = require("mssql");
// config for your database
var config = {
user: 'xxxxxxx',
password: 'xxxxxxx',
server: 'devsqlcl2:1433',
database: 'xxxxx',
port: "1433",
dialect:",ssql",
dialectOptiond:"SQLEXPRESS"
};
// connect to your database
sql.connect(config, function (err) {
if (err) console.log(err);
// create Request object
var request = new sql.Request();
// query to the database and get the records
request.query('select * from dbo.balance_papercut', function (err, recordset) {
if (err) console.log(err)
// send records as a response
res.send(recordset);
});
});
});
var server = app.listen(5000, function () {
console.log('Server is running..');
});
Now I've evolved into this part of node.js, but I'm still 100% lost in how to connect to the bank, however I'm facing the following error below.
I have no idea what it might be. The connection to the bank should not be a problem as I use the same credentials to access by a system in java.
C:\Users\roberto.pannain\Documents\WIDS_REST_Example>node server.js
Server is running..
tedious deprecated The default value for 'options.encrypt' will change from 'false' to 'true'. Please pass 'false' explicitly if you want to retain current behaviour. node_modules\mssql\lib\tedious.js:230:23
tedious deprecated Passing non-number values for options.port will throw an error in future tedious versions. Please pass a number instead. node_modules\mssql\lib\tedious.js:230:23
{ ConnectionError: Failed to connect to devsqlcl2:1433:1433 - getaddrinfo ENOTFOUND devsqlcl2:1433
at Connection.tedious.once.err (C:\Users\roberto.pannain\Documents\WIDS_REST_Example\node_modules\mssql\lib\tedious.js:237:17)
at Object.onceWrapper (events.js:315:30)
at emitOne (events.js:116:13)
at Connection.emit (events.js:211:7)
at Connection.socketError (C:\Users\roberto.pannain\Documents\WIDS_REST_Example\node_modules\tedious\lib\connection.js:1024:14)
at C:\Users\roberto.pannain\Documents\WIDS_REST_Example\node_modules\tedious\lib\connection.js:868:25
at GetAddrInfoReqWrap.callback (C:\Users\roberto.pannain\Documents\WIDS_REST_Example\node_modules\tedious\lib\connector.js:69:18)
at GetAddrInfoReqWrap.onlookupall [as oncomplete] (dns.js:79:17)
code: 'ESOCKET',
originalError:
{ ConnectionError: Failed to connect to devsqlcl2:1433:1433 - getaddrinfo ENOTFOUND devsqlcl2:1433
at ConnectionError (C:\Users\roberto.pannain\Documents\WIDS_REST_Example\node_modules\tedious\lib\errors.js:12:12)
at Connection.socketError (C:\Users\roberto.pannain\Documents\WIDS_REST_Example\node_modules\tedious\lib\connection.js:1024:30)
at C:\Users\roberto.pannain\Documents\WIDS_REST_Example\node_modules\tedious\lib\connection.js:868:25
at GetAddrInfoReqWrap.callback (C:\Users\roberto.pannain\Documents\WIDS_REST_Example\node_modules\tedious\lib\connector.js:69:18)
at GetAddrInfoReqWrap.onlookupall [as oncomplete] (dns.js:79:17)
message: 'Failed to connect to devsqlcl2:1433:1433 - getaddrinfo ENOTFOUND devsqlcl2:1433',
code: 'ESOCKET' },
name: 'ConnectionError' }
{ ConnectionError: Connection is closed.
at Request._query (C:\Users\roberto.pannain\Documents\WIDS_REST_Example\node_modules\mssql\lib\base.js:1330:37)
at Request._query (C:\Users\roberto.pannain\Documents\WIDS_REST_Example\node_modules\mssql\lib\tedious.js:526:11)
at Request.query (C:\Users\roberto.pannain\Documents\WIDS_REST_Example\node_modules\mssql\lib\base.js:1266:12)
at C:\Users\roberto.pannain\Documents\WIDS_REST_Example\server.js:28:17
at _poolCreate.then.catch.err (C:\Users\roberto.pannain\Documents\WIDS_REST_Example\node_modules\mssql\lib\base.js:275:7)
at <anonymous> code: 'ECONNCLOSED', name: 'ConnectionError' }