Hello,
I am tring to pass Date parameter in calling DB2 stored procedure through java code and getting following syntax error
"The method setDate(int, Date) in the preparedStatement si not applicable for arguement(int, Date)"
at line cstmt.setDate(2, dt);
My first parameter type is STRING and Seoncd prameter type is DATE in db2 stored procedure.
Actually code is not compiling due to syntax error
CallableStatement cstmt = null;
Connection con = null;
DateFormat dateFormat = new SimpleDateFormat("YYYY/MM/DD");
Date dt = new Date();
con = getDB2Connection();
cstmt = con.prepareCall("CALL MYSCHEMA.MYPROC(?, ?, ?, ?)");
cstmt.setString(1,"STRINGVAL1");
[COLOR="Red"]cstmt.setDate(2, dt);[/COLOR]
cstmt.registerOutParameter(3, Types.INTEGER);
cstmt.registerOutParameter(4, Types.VARCHAR);
//calling stroed procedure
cstmt.executeQuery();
int returnCode = cstmt.getInt(3);
String msg = cstmt.getString(4);
System.out.println(" code returned from stored procedure = " + returnCode);
System.out.println(" message returned from stored procedure = " + msg);
cstmt.close();
HOW TO PASS DATE PARAMETER THOUGH JAVA CALLING DB2 STORED PROCEDURE PLEASE.
I am tring to pass Date parameter in calling DB2 stored procedure through java code and getting following syntax error
"The method setDate(int, Date) in the preparedStatement si not applicable for arguement(int, Date)"
at line cstmt.setDate(2, dt);
My first parameter type is STRING and Seoncd prameter type is DATE in db2 stored procedure.
Actually code is not compiling due to syntax error
CallableStatement cstmt = null;
Connection con = null;
DateFormat dateFormat = new SimpleDateFormat("YYYY/MM/DD");
Date dt = new Date();
con = getDB2Connection();
cstmt = con.prepareCall("CALL MYSCHEMA.MYPROC(?, ?, ?, ?)");
cstmt.setString(1,"STRINGVAL1");
[COLOR="Red"]cstmt.setDate(2, dt);[/COLOR]
cstmt.registerOutParameter(3, Types.INTEGER);
cstmt.registerOutParameter(4, Types.VARCHAR);
//calling stroed procedure
cstmt.executeQuery();
int returnCode = cstmt.getInt(3);
String msg = cstmt.getString(4);
System.out.println(" code returned from stored procedure = " + returnCode);
System.out.println(" message returned from stored procedure = " + msg);
cstmt.close();
HOW TO PASS DATE PARAMETER THOUGH JAVA CALLING DB2 STORED PROCEDURE PLEASE.