-
Nov 9th, 2011, 12:21 PM
#1
JDBC - How to print prepared statement SQL if SQLException ?
Hello,
i would like to know if there is a way to print prepared statement SQL if SQLException occurs.
in JDBCTemplate class catch (SQLException ex) , the parameters of the prepareStatem are removed from SQL just before calling getExceptionTranslator().translate("PreparedStatem entCallback", sql, ex);
code from JDBCTemplate :
catch (SQLException ex) {
// Release Connection early, to avoid potential connection pool deadlock
// in the case when the exception translator hasn't been initialized yet.
if (psc instanceof ParameterDisposer) {
((ParameterDisposer) psc).cleanupParameters();
}
String sql = getSql(psc);
psc = null;
JdbcUtils.closeStatement(ps);
ps = null;
DataSourceUtils.releaseConnection(con, getDataSource());
con = null;
throw getExceptionTranslator().translate("PreparedStatem entCallback", sql, ex);
}
Question : does there is a way to redifine getSql() method to prevent it to remove parameters ?
regards,
jfdesmar
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules