2
我有以下存儲過程定義:如何使用Oracle JDBC中的Stored Proc中定義的IN OUT CLOB參數?
CREATE OR REPLACE PROCEDURE NOTIFY_INSERT (
FLAG IN VARCHAR2,
MESSAGE IN OUT CLOB,
SEQ_NO OUT NUMBER
)
AS
BEGIN
...
END;
現在我想調用JDBC這個存儲過程。但是,我得到一個異常說「java.sql.SQLException:參數類型衝突」。這是從行
call.execute();
我猜它與第二個參數,這是一個CLOB有關。
有沒有人有想法我做錯了什麼?
感謝您的幫助。
Connection connection = dataSource.getConnection();
CallableStatement call = null;
try {
call = connection.prepareCall("{ call NOTIFY_INSERT (?,?,?) }");
call.setString(1, flag);
call.registerOutParameter(2, Types.CLOB);
call.setString(2, message);
call.registerOutParameter(3, Types.NUMERIC);
call.execute();
sequenceNo = call.getLong(3);
message = call.getString(2);
} catch (SQLException e) {
e.printStackTrace();
} finally {
if (call != null) {
try { call.close(); } catch (SQLException sqle) {}
}
}
JDBC例外:
java.sql.SQLException: Parameter Type Conflict
at oracle.jdbc.driver.OraclePreparedStatement.processCompletedBindRow(OraclePreparedStatement.java:2480)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:4356)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:4595)
at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:10100)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.execute(OraclePreparedStatementWrapper.java:5693)
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
我仍然需要測試這個解決方案,但它看起來像正確的路要走。我會讓你知道,如果我能夠得到它的工作... –
@LateDownvoter:爲什麼downvote?爲什麼1個半月後? – rgettman
不確定誰投了票,但我投了票。這是正確的答案。 –