Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get SQL Query from preparedStatement

621250Jul 30 2008 — edited Jan 20 2015
Hi, There,

Is anybody aware about how to get the sql query created by prepared statement?

currently i am trying the following code to get my sql expression.

public static String getBetweenExpression(ConnectionManager connectionManager,Date startDate, Date endDate){
try {
String sqlQuery = "? AND ?";
PreparedStatement preparedStatement = connectionManager.getConnection().prepareStatement(sqlQuery);
preparedStatement.setDate(1, startDate);
preparedStatement.setDate(2, endDate);
return(preparedStatement.toString());
}catch(Exception ex){
ex.printStackTrace();
return null;
}
}

if any correction is there, it will be great.

thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 7 2008
Added on Jul 30 2008
4 comments
2,627 views