How do I get the SQL_ID of a query in my java code (JDBC)?
671656Jun 30 2010 — edited Jul 14 2010When 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