Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
2.4k views
in Java FTP by (120 points)
Hello,

i am trying to call one sql procedure with two parameters from java.
the first parameter is In parameter, the second is OUT.
the return value of this java method should be this second parameter value.

the following is my java code:

protected String getNextRunNumber() {
String runnumber=null;
String sql = "{call APIX.FNC_SST_EXPORT.GET_NEXT_RUNNUMBER (?,?)}";
CallableStatement state = null;
try{
Connection con= getDatabaseConnection();
state = con.prepareCall(sql);
state.setString(1, m_appKeyExport);
state.registerOutParameter(2,Types.NUMERIC,0);
state.execute();
ResultSet resultR = (ResultSet)state.getObject(2);
while (resultR.next()) {
runnumber=resultR.getBigDecimal(1).toString();
}
}
catch (SQLException e){System.out.println("You can not get the export next run number properly");}
return runnumber;
}

i got error message like:
java.lang.ClassCastException: java.math.BigDecimal

As far as i knew, if the parameter is number or decimal, we should give also the paramer scale to the method: state.registerOutParameter(), but i still get this error message.

Please help me to solve this problem.
Thanks a lot.

1 Answer

0 votes
by (162k points)
This forum is for FTP related queries.

But I don't think state.getObject() returns a ResultSet.

ResultSet resultR = (ResultSet)state.getObject(2);

Categories

...