如何从 CallableStatement 获取所有参数绑定信息?
我正在使用遗留代码,该代码使用一些复杂的逻辑来绑定 JDBC CallableStatement 中的 IN 和 OUT 参数。该代码看起来绑定了 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
“line 1, column7:
”没有帮助。它没有指向存储过程中的任何内容。
我编写了一个简单的独立测试用例来调用存储过程。使用与遗留代码相同的参数和绑定类型,并且它成功了。
我需要的是一种方法来比较遗留代码和我的独立测试中的两个 CallableStatement 对象,看看有什么不同。
有没有办法从 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 CallableStatement.getParameterMetaData()
http://download.oracle.com/javase /1.4.2/docs/api/java/sql/ParameterMetaData.html
You can use CallableStatement.getParameterMetaData()
http://download.oracle.com/javase/1.4.2/docs/api/java/sql/ParameterMetaData.html
JDBC CallableStatement 对象旨在表示对数据库服务器中存储过程的调用。
使用java.sql接口ParameterMetaData。
JDBC CallableStatement objects are designed to represent calls to stored procedures in the database server.
Use
java.sql Interface ParameterMetaData
.