This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Get SQL value out of PreparedStatement - Any API Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Get SQL value out of PreparedStatement - Any API" Watch "Get SQL value out of PreparedStatement - Any API" New topic
Author

Get SQL value out of PreparedStatement - Any API

Sam Gehouse
Ranch Hand

Joined: Jul 21, 2003
Posts: 281
Is there a way to get the SQL out of a PreparedStatement?

PreparedStatement prepStmnt = conn.prepareStatement("select * from table");

Is there any API that will let me extract the sql that is the inherent part of prepStmnt.

Goal is to get "select * from table" value out of prepStmnt variable.
stu derby
Ranch Hand

Joined: Dec 15, 2005
Posts: 333
Not in standard JDBC.

Some drivers may have vendor-supplied add-ons to do that.

Some people create "wrapper" classes that will store the SQL and the bind variable values and give them up on request.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

If you search this forum for 'DebuggableStatement' it will give you one option of that type, and links to a few more.

Dave
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Get SQL value out of PreparedStatement - Any API
 
Similar Threads
help! perhaps the problems of configuration of JDBC on Weblogic
SetNull in a PreparedStatement
Can PreparedStatements take care of this ?
Update D/b with Java variable
Can I use prep.execute to update a record?