這是用於調用存儲過程的Java代碼。我不斷收到一個錯誤說: java.lang.ClassCastException:oracle.jdbc.driver.OracleCallableStatementWrapper不符合oracle.jdbc.OracleCallableStatement從Java調用Oracle存儲過程
public Connection initiateDBConnection() throws NamingException,
SQLException {
Connection result = null;
InitialContext initialContext = new InitialContext();
DataSource datasource = (DataSource) initialContext
.doLookup(Constants.DATASOURCE_CONTEXT);
result = (Connection) WSJdbcUtil
.getNativeConnection((WSJdbcConnection) datasource
.getConnection());
return result;
}
public void callStoredProcedure(String procedureName,
Map<Integer, Object> map) throws SQLException, NamingException {
OracleCallableStatement statement = (OracleCallableStatement) initiateDBConnection()
.prepareCall(procedureName);
Iterator<Entry<Integer, Object>> params = map.entrySet().iterator();
while (params.hasNext()) {
Entry<Integer, Object> contents = params.next();
statement.setNString(contents.getKey(),
(String) contents.getValue());
System.out.println("Key: " + contents.getKey() + "Value: "
+ contents.getValue());
}
statement.execute();
statement.close();
}
顯然,這就是我試圖在第一,但我不斷收到SQL92令牌不兼容錯誤 – Bytekoder
可能是與你的語法或JDBC驅動程序不支持這種語法問題。 – nayakam