我有以下功能规范:
FUNCTION FUNC_GET_SOMETHING_FROM_DATABASE ( IN_parameter1 IN VARCHAR2, IN_parameter2 IN VARCHAR2, IN_parameter3 IN VARCHAR2, IN_parameter4 IN VARCHAR2, IN_parameter5 IN VARCHAR2, IN_parameter6 IN VARCHAR2) RETURN REFCURTYP;
以下是我在Java中调用Oracle函数的方法:
public List<SomeVO> getLogReport( String parameter1, String parameter2, String parameter3, String parameter4, String parameter5, String parameter6) throws BlahException, RemoteDataAccessException { Vector<Object> params = new Vector<Object>(); DataCollectionImpl<LogReportVO> someData = new DataCollectionImpl<LogReportVO>( LogReportVO.class); // IN Parameters params.add(parameter1); params.add(parameter2); params.add(parameter3); params.add(parameter4); params.add(parameter5); params.add(parameter6); //Out Parameter params.add(new DBParameter(DBParameter.OUT, DBParameter.CURSOR)); try { callStoredProcedure( Constants.FUNC_GET_SOMETHING_FROM_DATABASE, params); } catch (RemoteDataAccessException e) { throw new BlahException("LogReportDAO", "getLogReport", e.getMessage(), e.getRealException()); } return someData.getDataCollectionObjects(); }
我得到的错误是:
wrong number or types of arguments in call
其他信息:
protected void callStoredProcedure(String procedureName, Vector params) throws RemoteDataAccessException { callStoredProcedure(getSchema(), procedureName, params); } protected void callStoredProcedure(String schema, String procedureName, Vector params) throws RemoteDataAccessException { callStoredProcedure(getDatasource(), schema, procedureName, params); } protected void callStoredProcedure(String dataSourceName, String schema, String procedureName, Vector params) throws RemoteDataAccessException { getOracleConnection(dataSourceName).callStoredProcedure( getFullyQualifiedProcedureName(schema, procedureName), params); } private OracleConnection getOracleConnection(String datasource) { OracleConnection oraConn = null; try { oraConn = new OracleConnection(datasource); } catch (RemoteDataAccessException rdae) { log.fatal("BaseDAO.getOracleConnection " + rdae.getMessage(), rdae); } catch (Exception ie) { log.fatal("BaseDAO.getOracleConnection" + ie.getMessage(), ie); } return oraConn; }
答案 0 :(得分:1)
您的代码很可能没有考虑存储过程的返回值。
为什么不使用标准的JDBC方式调用存储过程呢?它就像一个魅力。
http://docs.oracle.com/javase/1.5.0/docs/guide/jdbc/getstart/callablestatement.html