简体   繁体   English

com.microsoft.sqlserver.jdbc.SQLServerException:'@ P0'附近的语法不正确

[英]com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '@P0'

I have an SQL server 2008 procedure which is returning one out parameter, i am giving call to it from java. 我有一个SQL server 2008程序,它返回一个参数,我从java调用它。 My code is given below 我的代码如下

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(); 但是infected.execute(); is generating the following error 正在生成以下错误

com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '@P0' com.microsoft.sqlserver.jdbc.SQLServerException:'@ P0'附近的语法不正确

kindly guide me where is problem 请指导我哪里有问题

As suggested by this link offered up by @GregHNZ, SQL Server requires a set of curly braces around the call. 正如@GregHNZ提供的这个链接所暗示的那样,SQL Server需要一组围绕调用的花括号。

The line in your code would look like this: 代码中的行如下所示:

infected = con.prepareCall("{ call countInfected(?) }");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 com.microsoft.sqlserver.jdbc.SQLServerexception:'='附近的语法不正确 - com.microsoft.sqlserver.jdbc.SQLServerexception:incorrect syntax near'=' com.microsoft.sqlserver.jdbc.SQLServerException: '=' 附近的语法不正确 - com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '=' com.microsoft.sqlserver.jdbc.SQLServerException: '|' 附近的语法不正确 - com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '|' com.microsoft.sqlserver.jdbc.SQLServerException:'GO'附近的语法不正确 - com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 'GO' com.microsoft.sqlserver.jdbc.SQLServerException: ')' 附近的语法不正确 - com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near ')' Microsoft SQL Server JPA存储过程com.microsoft.sqlserver.jdbc.SQLServerException:'{'附近的语法不正确 - Microsoft SQL Server JPA Stored Procedure com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '{' Vaadin错误:com.microsoft.sqlserver.jdbc.SQLServerException:'LIMIT'附近的语法不正确 - Vaadin error : com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 'LIMIT' com.microsoft.sqlserver.jdbc.SQLServerException 与 jpa - com.microsoft.sqlserver.jdbc.SQLServerException with jpa Error-com.microsoft.sqlserver.jdbc.SQLServerException:关键字“ BY”附近的语法不正确 - Error-com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near the keyword 'BY' com.microsoft.sqlserver.jdbc.SQLServerException:用户登录失败 - com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM