< ページ移動: 1 2 >
var Connection = require('tedious').Connection;var config = {server: 'DBSERVER\\MSSQL2019',authentication: {type: 'default',options: {userName: 'sa',password: 'hogepass'}},options: {encrypt: true,database: 'InazumaDB'}};var connection = new Connection(config);connection.on('connect', function(err) {if (err) {console.log(err);} else {console.log('CONNECT');}});connection.connect();
C:\Users\shinoda>node connect_test.jsConnectionError: Failed to connect to DBSERVER\MSSQL2019:1433 - getaddrinfo ENOTFOUND DBSERVER\MSSQL2019at Connection.socketError (C:\Users\shinoda\node_modules\tedious\lib\connection.js:1404:28)at C:\Users\shinoda\node_modules\tedious\lib\connection.js:1185:14at process.processTicksAndRejections (node:internal/process/task_queues:77:11) {code: 'ESOCKET',isTransient: undefined}
C:\Users\shinoda>sqlcmd -S DBSERVER\MSSQL2019 -U sa -P hogepass -d InazumaDB1> SELECT * FROM M_TOMODACHI;2> GOTOMO_ID TOMO_NAME TOMO_MEMO------- --------------------- ---------------------------------------1 アンモニア治郎 おごってくれるから友達2 クロム陽子 かわいいから友達14 ばいじん太郎 事業に失敗したからそろそろ切ろう(3 行処理されました)1>