I am working on a java based enterprise application and i am looking for ways to debug the plsql code on sql developer when the request comes from an application.
I am able to remote debug the pl sql code with a test sql program written locally invoking a specific procedure on my database.
i want to be able to achieve the same debug control when the request comes from an application.
By Right clicking on the db connection and clicking on remote debug, i get a 'Listener for JPDA' popup asking me for the port and local address. By entering the ip address of the machine where this application is deployed, I get the error - 'The debugger is not able to listen for JPDA using the specified parameters. Do you want to change the parameters?'
How do i get this working?
To debug an Oracle trigger, do the following: In Database Explorer, expand the Triggers folder and then double-click the trigger you have created and compiled for debugging. Switch to the SQL view to set a breakpoint for the trigger. The Main view is set as default.
SQL Developer's default “debug” action is to run until a breakpoint occurs. You can change this by going to Tools > Preferences, and clicking Debugger. Change the option that says “Start Debugging Option” to Step Into. This will allow you to click Debug and run to the first line of code.
With Oracle SQL Developer, you can browse database objects, run SQL statements and SQL scripts, and edit and debug PL/SQL statements. You can also run any number of provided reports, as well as create and save your own.
As mentioned by MDW, Sue Harper's blog is all you should need.
To set-up, basically, right-click on your connection in SQLDeveloper and select Remote Debug. Enter your database host and port to listen on. In your client code, e.g. in java, add the following:
private void debugPlSql() throws SQLException {
CallableStatement cstmt = null;
try {
cstmt = conn.prepareCall(
"call DBMS_DEBUG_JDWP.CONNECT_TCP('...my-ip-address...', 16000 )");
cstmt.executeUpdate();
} finally {
// cstmt.close() ...
}
}
Note my-ip-address
is your database server local IP address and 16000 is the debug port I used which brings me back to your question (which is now well out of date - so sorry about that)
I had this issue (alert) and the error isn't all that helpful but, in my case, it was just that the default port 4000 wasn't available. This is why my example uses port 16000 as this was available and worked fine when I changed the port in SQLDeveloper.
I call the debugPlSql
prior to executing the sql of interest.
Edit:
Don't forget:
GRANT DEBUG CONNECT SESSION TO myuser;
GRANT DEBUG ANY PROCEDURE TO myuser;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With