aspose file tools*
The moose likes JDBC and the fly likes JDBC logging? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC logging?" Watch "JDBC logging?" New topic
Author

JDBC logging?

Gabriel Beres
Ranch Hand

Joined: Sep 09, 2006
Posts: 61
Hi,

I'm using PreparedStatements to build my query, and bind the parameters.

What i would like to do is to see the final queries that are sent to the database. (For debug purpose)

What is the preffered way to do this? Should i configure a logger for JDBC?

Thanks

Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Try this: http://www.rgagnon.com/javadetails/java-0411.html

For more options (for more effort): http://code.google.com/p/log4jdbc/
Gabriel Beres
Ranch Hand

Joined: Sep 09, 2006
Posts: 61
Tim Moores wrote:Try this: http://www.rgagnon.com/javadetails/java-0411.html

For more options (for more effort): http://code.google.com/p/log4jdbc/


Unfortunatelly i get my connection through UCP, so the approach in the first link does not work.
Are there any simpler way than the second link?
Gabriel Beres
Ranch Hand

Joined: Sep 09, 2006
Posts: 61
Gabriel Beres wrote:
Tim Moores wrote:Try this: http://www.rgagnon.com/javadetails/java-0411.html

For more options (for more effort): http://code.google.com/p/log4jdbc/


Unfortunatelly i get my connection through UCP, so the approach in the first link does not work.
Are there any simpler way than the second link?



Is it possible to see the queries right in the database? i'm using oracle.
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3610
    
  60

Some databases have tools to do the logging on the database side. In Oracle for example, it is the SQL trace facility. Depending on how it is activated, it can record full SQL of the executed queries, values of bind variables and execution plans used. Other databases might offer similar tools.
Gabriel Beres
Ranch Hand

Joined: Sep 09, 2006
Posts: 61
Martin Vajsar wrote:Some databases have tools to do the logging on the database side. In Oracle for example, it is the SQL trace facility. Depending on how it is activated, it can record full SQL of the executed queries, values of bind variables and execution plans used. Other databases might offer similar tools.


Thanks i'll try that.
 
Don't get me started about those stupid light bulbs.
 
subject: JDBC logging?