How to get SQL Query from preparedStatement
621250Jul 30 2008 — edited Jan 20 2015Hi, 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