On 01/14/10 19:20, Thomas wrote:
The problem was the numbering of parameters in the registerOutParameter and the
setxxx Statement:

instead of
CallableStatement cs = conn.prepareCall("{ call APPL.\"myFunction\"(?, ?)");
cs.registerOutParameter(1, java.sql.Types.VARCHAR);
cs.setString(1, parm1);
cs.setString(2, parm2);

CallableStatement cs = conn.prepareCall("{ ? = call APPL.\"myFunction\"(?, ?)");
cs.registerOutParameter(1, java.sql.Types.VARCHAR);
cs.setString(2, parm1);
cs.setString(3, parm2);
was correct/needed.

Unfortunately there was no specific hint in any documentation I read mentioning
aspects of how the numbering needs to be done.

The API documentation for the java.sql.CallableStatement interface
(http://java.sun.com/j2se/1.5.0/docs/api/java/sql/CallableStatement.html and http://java.sun.com/javase/6/docs/api/java/sql/CallableStatement.html)
says, "Parameters are referred to sequentially, by number, with the
first parameter being 1."

The exception appears to be INOUT parameters, as described in the
Reference Manual at
http://db.apache.org/derby/docs/dev/ref/rrefjdbc75719.html, where the
same number is used for the parameter when you register it as an out
parameter and when you set its input value. If there are any errors in the Reference Manual topics on CallableStatement it would be helpful to know about them. The Reference Manual topics on JDBC generally focus on Derby-specific implementation details and other areas not covered by the API documentation.

Hope this helps --

Kim Haase

Reply via email to