views:

356

answers:

2

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?

+1  A: 

Hi myahya,

I think the getOriginalSql() method returns the String being sent to Oracle.

Vincent Malgrat
In JDBC, I wouldn't rely on vendorspecific methods.
BalusC
Thanks, it returns the string in the prepared statement, but without the set columns (question marks show up in the output).
myahya
+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
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