This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes Logging Oracle Prepared/Callable Statements Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Logging Oracle Prepared/Callable Statements" Watch "Logging Oracle Prepared/Callable Statements" New topic

Logging Oracle Prepared/Callable Statements

J Rosetto

Joined: Jun 03, 2008
Posts: 21
Does anyone know of a simple way of logging an Oracle prepared/callable statement? I tried calling toString() but all I receive is the object reference.

I believe the Oracle libraries have some functionality for producing their own logs but I'd rather a simpler solution which allows me to log just what I need.

Santhosh Kumar
Ranch Hand

Joined: Nov 07, 2000
Posts: 242
Have you tried log4jdbc? This library acts as a jdbc driver, logs the statements and delegates the request to underlying real driver.
J Rosetto

Joined: Jun 03, 2008
Posts: 21
Thanks Santhosh.

Unfortunately I am looking for a solution which will allow me to produce the log entries (using our company's bespoke logging library), rather than delegating the logging responsibility to another library.

I notice that the OraclePreparedStatement has a method called getRevisedSql(). I am guessing this provides what I need. Unfortunately I am using Commons DBCP, which means I only have access to DelegatingPreparedStatements which wrap the OraclePreparedStatements and so I have no access to this method.
I agree. Here's the link:
subject: Logging Oracle Prepared/Callable Statements
jQuery in Action, 3rd edition