Search code examples
javaoracle-databasejdbccallable-statement

How do I get all parameter binding information from a CallableStatement?


I'm working with legacy code that uses some convoluted logic to bind IN and OUT parameters in a JDBC CallableStatement. The code looks like it is binding the correct types for IN and OUT parameters, but when the CallableStatement is executed the Oracle stored procedure throws this Exception:

ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'STORED_PROC_ABC'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

The "line 1, column7:" isn't helpful. It's not pointing to anything in the stored proc.

I've written a simple stand-alone test case that calls the stored proc. with the same parameters and binding types as the legacy code, and it succeeds.

What I need is a way to compare the two CallableStatement objects in the legacy code and my stand-alone test to see what is different.

Is there a way to get the relevant parameter binding information (values and types) from a CallableStatement? If there is some third party library that will do this that would be great, otherwise I'll need a way to dig out the various bindings.

Thanks.


Solution

  • You can use CallableStatement.getParameterMetaData() http://download.oracle.com/javase/1.4.2/docs/api/java/sql/ParameterMetaData.html