| Author |
How can we view the generated sql using PreparedStatement ?
|
Sreejith kayappuram
Ranch Hand
Joined: Jun 24, 2008
Posts: 35
|
|
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 ?
|
Thanks
Sreejith
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
|
You can use a tool like p6spy for this.
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
Sreejith kayappuram
Ranch Hand
Joined: Jun 24, 2008
Posts: 35
|
|
Ok. Thanks for the reply
|
 |
 |
|
|
subject: How can we view the generated sql using PreparedStatement ?
|
|
|