This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes JDBC and the fly likes How to check query within PreparedStatement object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to check query within PreparedStatement object" Watch "How to check query within PreparedStatement object" New topic
Author

How to check query within PreparedStatement object

Vijay Arora
Greenhorn

Joined: Jun 25, 2007
Posts: 19
PreparedStatement pst=connection.prepareStatement("Select * from table where name=? and age=?");
pst.setString(1,"VIJAY");
pst.setInt(2,20);
ResultSet rs=pst.executeQuery();

Is there any method to print the query string replaced by name and age values.


vijay arora
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36599
    
  16
Please check your displayed name against the JavaRanch naming policy and amend it accordingly. It requires first name-space-last name.
suresh charan
Greenhorn

Joined: Jun 15, 2006
Posts: 8
Have a look at the following article

http://www.javaworld.com/javaworld/jw-01-2002/jw-0125-overpower.html?page=1
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to check query within PreparedStatement object
 
Similar Threads
Too few paramters
inserting a sequence value to the table
PreparedStatement and 'null' value in WHERE clause
Exception executing servlet with database connectivity
Regarding time taken by query