![](/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.