}
}
private static <T> int clearTable(ConnectionSource connectionSource, String tableName) throws SQLException {
DatabaseType databaseType = connectionSource.getDatabaseType();
DatabaseConnection connection = connectionSource.getReadWriteConnection();
StringBuilder sb = new StringBuilder(48);
if (databaseType.isTruncateSupported()) {
sb.append("TRUNCATE TABLE ");
} else {
sb.append("DELETE FROM ");
}
databaseType.appendEscapedEntityName(sb, tableName);
String statement = sb.toString();
logger.info("clearing table '{}' with '{}", tableName, statement);
CompiledStatement compiledStmt = null;
try {
compiledStmt = connection.compileStatement(statement, StatementType.EXECUTE, noFieldTypes);
return compiledStmt.runExecute();
} finally {
if (compiledStmt != null) {
compiledStmt.close();
}