[英]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.我正在处理使用一些复杂逻辑在 JDBC CallableStatement 中绑定 IN 和 OUT 参数的遗留代码。 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:代码看起来像是为 IN 和 OUT 参数绑定了正确的类型,但是在执行 CallableStatement 时,Oracle 存储过程会抛出此异常:
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. “ line 1, column7:
”没有帮助。 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.我需要一种方法来比较遗留代码中的两个 CallableStatement 对象和我的独立测试,看看有什么不同。
Is there a way to get the relevant parameter binding information (values and types) from a CallableStatement?有没有办法从 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您可以使用 CallableStatement.getParameterMetaData() http://download.oracle.com/javase/1.4.2/docs/api/java/sql/ParameterMetaData.ZFC35FDC70D5FC69D2698EZ83A2CA8
JDBC CallableStatement objects are designed to represent calls to stored procedures in the database server. JDBC CallableStatement 对象旨在表示对数据库服务器中存储过程的调用。
Use java.sql Interface ParameterMetaData
.使用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.一个 object 可用于获取有关 PreparedStatement object 中参数的类型和属性的信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.