Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How do I get the SQL_ID of a query in my java code (JDBC)?

671656Jun 30 2010 — edited Jul 14 2010
When I detect a long response time for a query in my java code, I log the query to a file so it can be looked into by our support team. I would like to include the SQL_ID along with the query. Can I get this info programatically in Java? I'm using Oracle's JDBC driver.

At the point where I detect the long running query, I still have the prepared statement object and result set objects available.

I've also noticed that my query is modified slightly (? for bind variables change to :1, :2, etc on the database side), so I cannot just select from v$sql where the text equals my query. I suppose I could do search and replace, but I'm trying to keep the logging impact to a minimum.

Thanks for any suggestions.
-Bill
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 11 2010
Added on Jun 30 2010
3 comments
3,701 views