• Post Reply Bookmark Topic Watch Topic
  • New Topic

How can we view the generated sql using PreparedStatement ?  RSS feed

 
Sreejith kayappuram
Ranch Hand
Posts: 35
  • 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
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. Thanks for the reply
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!