File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes PreparedStatment Logging Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "PreparedStatment Logging" Watch "PreparedStatment Logging" New topic
Author

PreparedStatment Logging

Gobind Singh
Ranch Hand

Joined: Aug 04, 2006
Posts: 62
Please can someone tell me how to print out (or log via log 4j) the preparedstatment sent through JDBC.

If I have a java.sql.Statement object which uses a query like:
select name from company where sector = 'USA'
then I can print out this entire query to my log file every time it is executd.

If I have a preparedStatement like:
select name from company where sector = ?

Then when I print the sql I get "select name from company where sector = ?
"
But I want to be able to see what has binded to the ? parameter marker at runtime.

Any ideas?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Its always worth searching the forum before posting. Your question may have already been answered.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
 
subject: PreparedStatment Logging
 
Similar Threads
Problem in returning the username
Is it possible to view the SQL that got executed?
Two instances of PreperedStatment
Prepared statement null setting
My query is not working!!!