Controlling the type value of the OUT parameter
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.Types;
public class Test {
public static void main(String[] args) throws Exception {
Connection conn = DriverManager
.getConnection("...", "username", "password");
String query = "{CALL GETDATE(?,?)}";
CallableStatement callableStatement = (CallableStatement) conn
.prepareCall(query);
callableStatement.setInt(1, 123);
callableStatement.registerOutParameter(1, Types.DATE);
callableStatement.executeQuery();
Date date = callableStatement.getObject(2, Date.class);
}
}
Related examples in the same category