1 问题背景
最近在做自己的开源项目,使用jdbc去调用oracle的一个分页存储过程,如下图,1出执行的代码始终得不到数据(rs.next=false).几经折腾,在eclipse中调试java代码,没有找到原因.
在pl/sql developer中调试存储过程,也没有找到原因,由于中pl/sql developer中调试存储过程需要手动给参数赋值,结果每次cursor变量都有值,但就是java中调用没有值.后来很想看到在调试java代码中的存储过程时,能否同时进入pl/sql developer中,调试存储过程sql代码,等存储过程sql代码调试完,再返回java中,接着调试java代码.带着疑问,在google上不断搜索.以下就是解决方案.
2 详细步骤
a)Open the package in Oracle SQL developer. Right click both body and spec and compile for DEBUG
Note: If the package is using some user defined type objects as input or output then compile those objects for DEBUG.
b)Go to tools -> Preferences -> Debugger. Select the option Prompt for Debugger host for Database Debugging.
c)Right click the DB connection and start the remote debug session
It will open the Listen for JPDA dialog. In Local address enter the ip address of the machine and hit OK.
This will start the debug listener as follows.
d)Now in the java program calling the PL/SQL package before the actual PL/SQL call enter the following code
https://blogs.oracle.com/shay/entry/debugging_java_and_plsql_toget(flash视频,演示jdeveloper中如何实现)