SQL存储过程调用失败,索引超出范围

时间:2016-08-02 19:59:21

标签: sql sql-server stored-procedures java-stored-procedures

我试图从我的java代码中执行SQL Server中的存储过程。这个存储过程用于其他一些语言,从长远来看它工作得很好。现在我需要将它集成到我的Java应用程序中。我的表中有15列。当我在我的java代码中尝试这个时,抛出它 com.microsoft.sqlserver.jdbc.SQLServerException:索引11超出范围
我还看到"错误:0,SQLState:S1093"

我的存储过程

ALTER PROCEDURE [dbo].[user_input_sp] 

@Username   VARCHAR(10)=NULL, 
@UserKey    VARCHAR(50)=NULL, 
@ReqTime    DATETIME=null, 
@ResTime    DATETIME=null, 
@Req            TEXT=null,
@Res            TEXT=null,
@condition      TEXT=null,
@ID             INT=null,
@Address        VARCHAR(8000) = NULL,
@Task           VARCHAR(50) = NULL,
@Direction          INT=0, 
@Seq                INT=0, 
@RR                 BIT=0, 
@Correction         VARCHAR(8) = NULL,
@PendingTrans   VARCHAR(50) = NULL,
@ForwardID          VARCHAR(50) = NULL,
@Command        VARCHAR(50) = NULL


AS  
    DECLARE @TSqno int
    @IF @Direction=0
    BEGIN
        EXECUTE Basp_NewKey 'web_log', @TSqno OUTPUT
        Insert into cbscne dbo WebServiceLog( Order, US_Name, US_Key , US_ReqD, US_ResD, US_Req , US_Res, cond, ID ,Address, Task, Command)
        values (@TSqno, @Username, @UserKey, @ReqTime, @ResTime, @Req ,@Res, @condition, @ID ,@Address, @Task ,@Command)
    END
.......

我的java代码

public vold addWebServiceLogRequest(UserInput cd){
 sessionFactory = sqlServerEMFactory.unwrap(SessionFactory.class); 
 Session sessionForSave = sessionFactory.openSession(); 
 sessionForSave.beginTransaction(); 

    sessionForSave.doReturningWork(connection-> {
        try(CallableStatement cstmt = connection.prepareCall("{call user_input_sp(?,?,?,?,?,?,?,?,?)}")) { 
            cstmt.setInt("indicator", 0); 
            cstmt.setString("Username",cd.getInterfaceName()); 
            cstmt.setInt("User_code",cd.getCaseId()); 
            cstmt.setTimestamp("RetrieveDate",cd.getRequestDate()); 
            cstmt.setTimestamp("ReturnDate",cd.getResponseDate()); 
            cstmt.setString("Req",cd.getRequestxml()); 
            cstmt.setString("Res",cd.getResponsexml()); 
            cstmt.setString("Task",cd.getTask()); 
            cstmt.setString("flow",null); 
            cstmt.execute(); 
            cstmt.close(); 
            connection.close(); 
            return null; 

        }
    });
}

0 个答案:

没有答案