我试图通过java调用oracle db函数,如下所示:
StoredProcedureCall getTaxProcedureCall = new StoredProcedureCall();
getTaxProcedureCall.setProcedureName("getTaxByCustomerId");
getTaxProcedureCall.addNamedArgument("ImpactedParty");
getTaxProcedureCall.addNamedArgument("ImpactedPartyType");
getTaxProcedureCall.addNamedOutputArgument("P_TAX");
getTaxProcedureCall.addNamedOutputArgument("A_TAX");
DataReadQuery query = new DataReadQuery();
query.setCall(getTaxProcedureCall);
query.addArgument("ImpactedParty");
query.addArgument("ImpactedPartyType");
Vector queryValues = new Vector();
queryValues.add(cusId);
queryValues.add("CSID");
Vector<DatabaseRecord> records = (Vector<DatabaseRecord>)TransactionContext.getCurrent().getUnitOfWork().executeQuery(query, queryValues);
return records;
但是当它运行时,它给出了:oracle.jdbc.driver.OraclePreparedStatementWrapper无法强制转换 到java.sql.CallableStatement
在Vector<DatabaseRecord> records = (Vector<DatabaseRecord>)TransactionContext.getCurrent().getUnitOfWork().executeQuery(query, queryValues);
答案 0 :(得分:0)
我已将StoredProcedureCall
替换为SQLCall
并传递sql字符串,如:
SELECT getTaxByCustomerId(#ImpactedParty, #ImpactedPartyType, #TaxProfile) AS P_TAX FROM DUAL
现在它工作正常。