I'm in a huge trouble with my call to a PLSQL from Java. Here's my code:
static final String PLSQL = "{call DBK_PDG_METADATI_CEDOLINO.dbp_main(?,?,?,?,?,?,?,?,?)}";
Connection conn = DataSourceUtils.getConnection(jdbcTemplate.getDataSource());
CallableStatement cs = conn.prepareCall(PLSQL);
for (Cedolino item : items) {
LOG.info("################# ELABORAZIONE CEDOLINO " + item.getTestata().getAnagrafica().getCodFiscaleAmministrato() + " #################");
cedolini.getCedolino().add(item);
setParametersForPlSql(cs, item);
try{
cs.execute();
}catch(SQLException e){
LOG.info(e.toString());
}
}
cs.close();
conn.close();
private void setParametersForPlSql(CallableStatement cs, Cedolino ced){
try {
cs.setInt("tipo_lancio", 1);
cs.setString("iscr", ced.getTestata().getTrattamento().getIscrizione().trim());
cs.setString("rts", ced.getTestata().getDpt().trim());
cs.setString("codfisc", ced.getTestata().getAnagrafica().getCodFiscaleAmministrato().trim());
cs.setString("lingua", this.lingua);
cs.setString("file_name", null);
cs.setString("dir_spec", null);
cs.setString("stato_elab", "S");
cs.setString("descr_elab", null);
} catch (SQLException e) {
e.printStackTrace();
}
}
This code works good except for cs.execute, that gives me this error
java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'DBP_MAIN'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
I checked a thousand times, parameters and types and numbers match perfectly. DB connection is also good, because I do some caching first and it works.
Already tried to delete DBK_PDG_METADATI_CEDOLINO but nothing it is needed.
Can you help me to figure out it?
?), you should use index-based setters (although I'm not 100% sure if Oracle may allow named any way in that case).