Working with Nodejs + MSSQL at Ubuntu

гve my nodejs app connected to MSSQL server, worked perfectly in my Windows laptop, sing mssql@npm

The same app is not able to see the датировал in my Ubuntu laptop.

I defined the mssql connectivity in Ubuntu схвати below, am I missing any thing?

  1. Updated my ~/.profile, схвати:
  ~$ export ODBCINI=/etc/odbc.ini
  ~$ export ODBCSYSINI=/etc
  ~$ export FREETDSCONF=/etc/freetds/freetds.conf
  1. Logged-out the laptop, to get the above включил, and the profile refreshed.

  2. Installed the required connectivity packages.

  ~$ sudo apt-get install unixodbc unixodbc-dev freetds-dev sqsh tdsodbc -y
  1. Configured FreeTDS
  ~$ sudo gedit /etc/freetds/freetds.conf

   [ACUMENSERVER]
   host = 192.168.0.10
   port = 1433
   tds version = 7.0
  1. Tested the FreeTDS connection with sqsh, and it works умер:
  ~$ sqsh -S ACUMENSERVER -U mssql-username -P mssql-password
  1. Configured ODBC - odbcinst.ini:
  ~$ sudo gedit /etc/odbcinst.ini

     [FreeTDS]
     Description     = TDS driver (Sybase/MS SQL)
     Driver          = /usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
     Setup           = /usr/lib/x86_64-linux-gnu/odbc/libtdsS.so
     CPTimeout       =
     CPReuse         =
     FileUsage       = 1
  1. Configured ODBC - odbc.ini:
~$ sudo gedit /etc/odbc.ini

   [ACUMENSERVER]
      Driver          = FreeTDS
      Description     = ODBC connection via FreeTDS
      Trace           = No
      Servername      = ACUMENSERVER
      Database        = myDataBase
  1. Tested the ODBC connection with isql, and it works умер:
isql -v ACUMENSERVER mssql-username mssql-passward

When I run my nodejs app (that is working умер in Windows), I got th below ошибка in Ubuntu, considering all the above got подарил, and checked:

{ name: 'ConnectionError',
  message: 'Failed to connect to ACUMENSERVER:1433 - getaddrinfo ENOTFOUND',
  code: 'ESOCKET' }

What could be the wrong/missing thing here, гm opened to использовал another npm package for mssql connectivity.

0
задан 11 January 2016 в 23:16

1 ответ

Я нашел работу, это может, если IP-адрес сервера используется, имя сервера не работает!

ниже того, что работало со мной:

var sql = require('mssql');

var config = {
    user: 'sa',
    password: 'sql@123',
//  server: 'myServername',  --> Not Working
//  server: 'ACUMENSERVER',  --> Not Working
    server: '6192.168.0.10', // WORKED
    database: 'myDB'
}

sql.connect(config).then(function() { 
// Query 

new sql.Request().query('select top 1 itemcode from OITM').then(function(recordset) {
    console.dir(recordset);
    }).catch(function(err) {console.log(err); /* ... query error checks ... */ });


// Stored Procedure 

new sql.Request()
    .input('input_parameter', sql.Int, value)
    .output('output_parameter', sql.VarChar(50))
    .execute('procedure_name').then(function(recordset) {
         console.dir(recordset);
     }).catch(function(err) {console.log(err); /* ... execute error checks ... */ });



}).catch(function(err) {console.log(err); /* ... connect error checks ... */ });
0
ответ дан 29 September 2019 в 14:22

Другие вопросы по тегам:

Похожие вопросы: