}
catch (Exception e) {
throw new UnableToCreateStatementException(String.format("Exception while locating statement for [%s]",
sql), e);
}
final RewrittenStatement rewritten = rewriter.rewrite(my_sql, current.getParameters(), context);
PreparedStatement stmt = null;
try {
try {
stmt = connection.prepareStatement(rewritten.getSql());
}
catch (SQLException e) {
throw new UnableToCreateStatementException(e);
}
try {
for (PreparedBatchPart part : parts) {
rewritten.bind(part.getParameters(), stmt);
stmt.addBatch();
}
}
catch (SQLException e) {
throw new UnableToExecuteStatementException("Exception while binding parameters", e);
}
try {
final long start = System.currentTimeMillis();
final int[] rs = stmt.executeBatch();
log.logPreparedBatch(System.currentTimeMillis() - start, rewritten.getSql(), parts.size());
return rs;
}
catch (SQLException e) {
throw new UnableToExecuteStatementException(e);
}