myahya
myahya

Reputation: 3171

Printing SQL Query In PreparedStatement in oracle.jdbc.driver.OraclePreparedStatement

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?

Upvotes: 1

Views: 11329

Answers (2)

skaffman
skaffman

Reputation: 403461

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.

Upvotes: 5

Vincent Malgrat
Vincent Malgrat

Reputation: 67722

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

Upvotes: 1

Related Questions