File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can we view the generated sql using PreparedStatement ?

 
Sreejith kayappuram
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
is there any way we can get the SQL query generated with replacing '?' with its corresponding 'value'.
eg.
PreparedStatement stmt = conn.prepareStatement("select id, name from users where id = ?");
stmt.setInt(1);

i would like to get an output in console like " select id, name from users where id = 1 "

I have heard like iPreparedStatement or something for this purpose only. I am not sure about that.

is there any way ?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use a tool like p6spy for this.
 
Sreejith kayappuram
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. Thanks for the reply
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic