📌  相关文章
📜  无法连接到 localhost:1433 - 自签名证书 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:25.530000             🧑  作者: Mango

代码示例1
const config = {
  port: parseInt(process.env.DB_PORT, 10),
  server: process.env.DB_HOST,
  user: process.env.DB_USER,
  password: process.env.DB_PASS,
  database: process.env.DB_Database,
  stream: false,
  options: {
    trustedConnection: true,
    encrypt: true,
    enableArithAbort: true,
    trustServerCertificate: false,

  },
}

sql.connect(config).then(pool => {
  if (pool.connecting) {
    console.log('Connecting to the database...')
  }
  if (pool.connected) {
    console.log('Connected to SQL Server')
  }
})