• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC logging?

 
Gabriel Beres
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 2895
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic