반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- MSsql
- FCM
- jquery
- Maven
- node.js
- git
- SpringBoot
- nodejs
- jenkins
- config
- spring3
- mysql
- MariaDB
- Push
- javascript
- security
- yona
- Java
- Tomcat
- docker
- ajax
- pwa
- rocky9
- PM2
- NextJS
- Eclipse
- mybatis
- Next.js
- popup
- centos7
Archives
- Today
- Total
종이 한장 차이...
Linux 또는 windows에서 node.js 용 MSSQL 접속 테스트 본문
728x90
반응형
SMALL
Linux 또는 windows 환경에서 node.js용 MSSQL module 을 사용한 DB 접속 테스트 시 참고.
1. mssql-connTest.js 파일을 아래와 같이 만든다.
const sql = require("mssql");
const config = {
port: XXXX,
user: 'graykang',
password: 'pwd1234',
server: '127.0.0.1',
database: 'test',
stream: false,
options: {
encrypt: false,
enableArithAbort: true
},
};
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 getdate() as 현재서버시간', function (err, recordset) {
if (err) console.log(err)
// send records as a response
console.log(recordset);
});
});
2. package.json 파일을 아래과 같이 만든다.
728x90
반응형
SMALL
{
"name": "mssql-connTest",
"version": "1.0.0",
"description": "",
"main": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "npm i mssql && node employee.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"mssql": "^10.0.2"
}
}
3. npm start 를 실행한다.
[graykang@test]$ npm start
> mssql-conTest@1.0.0 start
> npm i mssql && node mssql-connTest.js
up to date, audited 142 packages in 1s
55 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
{
recordsets: [ [ [Object] ] ],
recordset: [ { '현재서버시간': 2024-02-26T16:20:44.893Z } ],
output: {},
rowsAffected: [ 1 ]
}
끝.
728x90
반응형
LIST
'node.js' 카테고리의 다른 글
nodejs OR nextjs 에서의 new Date 사용시 참고. (0) | 2024.09.04 |
---|---|
pm2-logrotate Downgrade v2.7.0 to v2.6.0 (0) | 2024.04.17 |
pm2 cluster + nextJS (0) | 2024.04.15 |
pm2 특정 app프로세스 강제 종료 및 초기화. (0) | 2024.03.19 |
pm2-logrotate (pm2 log 관리) (0) | 2024.03.13 |
Comments