Java コードから SQL Server でストアド プロシージャを実行しようとしています。このストアド プロシージャは他の言語で使用されており、ずっと前から正常に機能していました。次に、Java アプリに統合する必要があります。テーブルに 15 列あります。Java コードでこれを試したところ、
com.microsoft.sqlserver.jdbc.SQLServerException: The index 11 is out of range がスローされ、 "Error: 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;
}
});
}