![](/img/trans.png)
[英]com.microsoft.sqlserver.jdbc.SQLServerexception:incorrect syntax near'='
[英]com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '@P0'
我有一个SQL server 2008程序,它返回一个参数,我从java调用它。 我的代码如下
存储过程代码是
Create PROCEDURE countInfected @infected int out
AS
Select @infected = COUNT(*) from userInfo
where userID NOT IN (Select userID from deletedInfo);
Java调用代码是
CallableStatement infected = null;
infected = con.prepareCall("call countInfected(?)");
infected.registerOutParameter(1, java.sql.Types.INTEGER);
infected.execute();
System.out.println("Infected"+ infected.getInt(1));
但是infected.execute(); 正在生成以下错误
com.microsoft.sqlserver.jdbc.SQLServerException:'@ P0'附近的语法不正确
请指导我哪里有问题
正如@GregHNZ提供的这个链接所暗示的那样,SQL Server需要一组围绕调用的花括号。
代码中的行如下所示:
infected = con.prepareCall("{ call countInfected(?) }");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.