private PreparedStatement buildPreparedStatement(boolean allowArrayParameters) {
log.debug("Parameters => {}", paramIndexValues.values());
if (preparedStatement == null) {
try {
if (columnNames != null && columnNames.length > 0) {
preparedStatement = connection.getJdbcConnection().prepareStatement(parsedQuery, columnNames);
} else if (returnGeneratedKeys) {
preparedStatement = connection.getJdbcConnection().prepareStatement(parsedQuery, Statement.RETURN_GENERATED_KEYS);
} else {
preparedStatement = connection.getJdbcConnection().prepareStatement(parsedQuery);
}
} catch (SQLException ex) {
throw new Sql2oException(String.format("Error preparing statement - %s", ex.getMessage()), ex);
}
connection.registerStatement(preparedStatement);
}
for (Map.Entry<Integer, Object> entry : paramIndexValues.entrySet()) {
try {
getQuirks().setParameter(preparedStatement, entry.getKey(), entry.getValue());
} catch (SQLException e) {
throw new RuntimeException(String.format("Error adding parameter '%s' - %s", entry.getKey(), e.getMessage()), e);
}
}
paramIndexValues.clear();
return preparedStatement;
}