在 Oracle 10g/11g 中有一个存储过程,如下所示:
CREATE OR REPLACE
PROCEDURE SP_SOME_PROC ( PRM_ID IN NUMBER , START_DATE IN DATE, RESULT OUT BOOLEAN)
is...
使用以下代码调用它并获取结果:
String sql = "{call SP_SOME_PROC(?,?,?) }";
callableStatement = conn.prepareCall(sql);
callableStatement.setLong(1, theid);
callableStatement.setDate(2, new java.sql.Date(startDate.getTime()));
callableStatement.registerOutParameter(3, java.sql.Types.BOOLEAN);
callableStatement.executeUpdate();
Boolean result = callableStatement.getBoolean(3);
但是,上面的代码会产生如下异常
[10/8/13 2:28:24:736 EEST] 0000009a SystemErr R java.sql.SQLException: Invalid column type: 16
[10/8/13 2:28:24:737 EEST] 0000009a SystemErr R at oracle.jdbc.driver.OracleStatement.getInternalType(OracleStatement.java:3950)
[10/8/13 2:28:24:737 EEST] 0000009a SystemErr R at oracle.jdbc.driver.OracleCallableStatement.registerOutParameterInternal(OracleCallableStatement.java:135)
[10/8/13 2:28:24:737 EEST] 0000009a SystemErr R at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:304)
[10/8/13 2:28:24:737 EEST] 0000009a SystemErr R at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:393)
[10/8/13 2:28:24:737 EEST] 0000009a SystemErr R at oracle.jdbc.driver.OracleCallableStatementWrapper.registerOutParameter(OracleCallableStatementWrapper.java:1569)
我尝试了其他组合,例如
String sql = "{? = call SP_SOME_PROC(?,?) }";
callableStatement = conn.prepareCall(sql);
callableStatement.registerOutParameter(1, OracleTypes.BOOLEAN);
但没有运气!