[Solved] java.lang.Exception: java.sql.SQLException: ORA-06553: PLS-306: wrong number or types of arguments in call to ‘SP_ ACT_ DAYACCOUNTAMOUNT’

Problems encountered in fixing bugs yesterday

The operation is to call procedures with Java program, and the database is Oracle

However, after Java calls this save, the following error is reported in the console during execution:

java.lang.Exception: java.sql.SQLException: ORA-06553: PLS-306: wrong number or types of arguments in call to ‘SP_ ACT_ DAYACCOUNTAMOUNT’

There is still no good way to search the results on the Internet. Finally, the problem was solved by colleagues

The reason is that there is a problem in passing parameters. Since this Oracle is transplanted from DB2, an out parameter is added to the original one for return, so the number of parameters is changed from 8 to 9. More vcur out sys in parameter_ Refcursor

The final solution is:

Therefore, the Java program should be changed accordingly

..............
    String procedure = "call  sp_act_dayaccountamount(?,?,?,?,?,?,?,?,?)";  //Add one more parameter
    cstmt = con.prepareCall(procedure);
    ..............
    ..............
    ..............
    cstmt.setLong(7, vo.getLedgerID());
    cstmt.setLong(8, vo.getCurrencyID());
    cstmt.registerOutParameter(9, OracleTypes.CURSOR);  //add
    cstmt.execute();
    //rs = cstmt.getResultSet();
    rs = (ResultSet)cstmt.getObject(9);   //add
    ..............

Because the database operation of this program uses hibernate, you need to add the above sentences, such as comments. And you need to add one more when you transfer parameters?, Otherwise, “invalid column index” will be reported

Similar Posts: