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 ide开发者_运维技巧as how to achieve that?
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.
I think the getOriginalSql()
method returns the String being sent to Oracle.
精彩评论