简体   繁体   中英

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.

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

JDBC CallableStatement objects are designed to represent calls to stored procedures in the database server.

Use java.sql Interface ParameterMetaData .

An object that can be used to get information about the types and properties of the parameters in a PreparedStatement object.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM