0

我正在尝试从我的 java 代码中执行 SQL Server 中的存储过程。此存储过程以其他语言使用,并且从很久以前就可以正常工作。现在我需要将它集成到我的 java 应用程序中。我的表中有 15 列。当我在我的 java 代码中尝试这个时,它抛出 com.microsoft.sqlserver.jdbc.SQLServerException: The index 11 is out of range
我还看到“错误: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; 

        }
    });
}
4

0 回答 0