I need to see the query being sent to Oracle from a Java program. In the PostgreSQL JDBC driver, toString() does the job, but the same does not apply to prepared statements from Oracle JDBC implementation. Any ideas how to achieve that?
views:
356answers:
2
+1
A:
Hi myahya,
I think the getOriginalSql()
method returns the String being sent to Oracle.
Vincent Malgrat
2010-05-06 13:21:49
In JDBC, I wouldn't rely on vendorspecific methods.
BalusC
2010-05-06 13:47:03
Thanks, it returns the string in the prepared statement, but without the set columns (question marks show up in the output).
myahya
2010-05-07 08:43:48
+2
A:
Check out Log4Jdbc. This sits between your JDBC driver and the application, logging all DB traffic that goes back and forth. It's driver-agnostic, so need for driver-specific logging code.
Extremely handy, and would be even handier if it supported DataSources, but sadly it doesn't.
skaffman
2010-05-06 13:35:53
It was very helpful, I could not follow the installation instructions on the site, but I managed to get the debugging information I needed through it. Thanks.
myahya
2010-05-07 08:44:57