问题描述
我有一个带有npm mssql模块的节点js app。我购买了一个云Windows 2012服务器,当试图调用存储过程时,它会抛出错误。
在ps.prepare上抛出错误(exec usp_Get_Cars @param,函数(错误)
I have a node js app with the npm mssql module. I have purchased a cloud Windows 2012 server and when trying to call the stored procedure, it throws the error.
Throws error at ps.prepare("exec usp_Get_Cars @param", function(err)
var express = require('express');
var app = express();
var router = express.Router();
var util = require('util');
var recieve = require('./recieve');
var userID = "7DF506E1-700D-4D30-8162-74A903743561";
app.use('/node_modules', express.static(__dirname + '/node_modules'));
app.use('/style', express.static(__dirname + '/style'));
app.use('/script', express.static(__dirname + '/script'));
var sql = require('mssql');
var config = {
user: 'prod_admin',
password: 'myPassword',
server: 'serverName',
database: 'elements'
};
app.get("/getCars/:userID", function(req, res) {
var userID = req.params.userID;
var connection = new sql.Connection(config, function(err) {
var ps = new sql.PreparedStatement(connection);
ps.input('param', sql.NVarChar(sql.MAX));
ps.prepare("exec usp_Get_Cars @param", function(err) {
ps.execute({
param: userID
}, function(err, recordset) {
console.log('Recordset: ' + JSON.stringify(recordset));
res.send(recordset);
ps.unprepare(function(err) {
console.log('Error on unprepare: ' + err);
});
});
});
});
});
app.get('/', function(req, res) {
res.sendFile('home.html', {
'root': __dirname + '/templates'
});
});
app.listen(3000, function() {
console.log('Node server running @ http://localhost:3000');
});
有什么想法吗?
我尝试了什么:
我尝试搜索出现此错误的原因,但无法找到与mssql相关的任何内容或节点。您可以在此处看到 。
似乎在建立连接之前发生了错误。我在最后添加了connection.close(),但是没有做任何事情。根据这里的,它说调用ps.unprepare()应该将连接释放回游泳池。但是,当在我的本地Windows 10机器上运行时,它运行正常。
我可能需要在服务器上设置一些东西吗?
Any ideas?
What I have tried:
I did try searching for why this error occurs, but can't find anything relating to mssql or node. You can see the code that throws the error here.
It seems like the error occurs before the connection is made. I have added connection.close() at the end, but that didn't do anything. And according to the docs here, it says that calling ps.unprepare() should release the connection back to the pool. However, when running this on my local Windows 10 machine, it works just fine.
Could there be something I need to setup on the server?
推荐答案
这篇关于节点mssql抛出错误:池正在耗尽,无法接受工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!