java com.microsoft.sqlserver.jdbc.SQLServerException: '@P0' 附近的语法不正确
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17268901/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '@P0'
提问by WiXXeY
I have an SQL server 2008 procedure which is returning one out parameter, i am giving call to it from java. My code is given below
我有一个 SQL Server 2008 过程,它返回一个 out 参数,我从 java 调用它。我的代码如下
Stored procedure code is
存储过程代码是
Create PROCEDURE countInfected @infected int out
AS
Select @infected = COUNT(*) from userInfo
where userID NOT IN (Select userID from deletedInfo);
Java Calling Code is
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));
but infected.execute(); is generating the following error
但受感染.execute(); 正在生成以下错误
com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '@P0'
com.microsoft.sqlserver.jdbc.SQLServerException: '@P0' 附近的语法不正确
kindly guide me where is problem
请指导我哪里有问题