Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Get SQL value out of PreparedStatement - Any API

 
Sam Gehouse
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you search this forum for 'DebuggableStatement' it will give you one option of that type, and links to a few more.

Dave
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic