use of org.jumpmind.db.sql.SqlException in project symmetric-ds by JumpMind.
the class AbstractSymmetricDialect method truncateTable.
public void truncateTable(String tableName) {
String quote = platform.getDdlBuilder().isDelimitedIdentifierModeOn() ? platform.getDatabaseInfo().getDelimiterToken() : "";
boolean success = false;
int tryCount = 5;
while (!success && tryCount > 0) {
try {
Table table = platform.getTableFromCache(tableName, false);
if (table != null) {
platform.getSqlTemplate().update(String.format("truncate table %s%s%s", quote, table.getName(), quote));
success = true;
} else {
throw new RuntimeException(String.format("Could not find %s to trunate", tableName));
}
} catch (SqlException ex) {
log.warn("", ex);
AppUtils.sleep(5000);
tryCount--;
}
}
}
use of org.jumpmind.db.sql.SqlException in project symmetric-ds by JumpMind.
the class DbFill method updateRandomRecord.
private void updateRandomRecord(Table table) {
DmlStatement updStatement = createUpdateDmlStatement(table);
Row row = createRandomUpdateValues(updStatement, table);
try {
platform.getSqlTemplate().update(updStatement.getSql(), row.toArray(table.getColumnNames()));
if (verbose) {
log.info("Successful update in " + table.getName());
}
} catch (SqlException ex) {
log.info("Failed to process {} with values of {}", updStatement.getSql(), ArrayUtils.toString(row.toArray(table.getColumnNames())));
if (continueOnError) {
if (debug) {
log.info("", ex);
}
} else {
throw ex;
}
}
}
use of org.jumpmind.db.sql.SqlException in project symmetric-ds by JumpMind.
the class MySqlSymmetricDialect method switchCatalogForTriggerInstall.
@Override
protected String switchCatalogForTriggerInstall(String catalog, ISqlTransaction transaction) {
if (catalog != null) {
Connection c = ((JdbcSqlTransaction) transaction).getConnection();
String previousCatalog;
try {
previousCatalog = c.getCatalog();
c.setCatalog(catalog);
return previousCatalog;
} catch (SQLException e) {
throw new SqlException(e);
}
} else {
return null;
}
}
use of org.jumpmind.db.sql.SqlException in project symmetric-ds by JumpMind.
the class MsSqlSymmetricDialect method switchCatalogForTriggerInstall.
@Override
protected String switchCatalogForTriggerInstall(String catalog, ISqlTransaction transaction) {
if (catalog != null) {
Connection c = ((JdbcSqlTransaction) transaction).getConnection();
String previousCatalog = null;
try {
previousCatalog = c.getCatalog();
c.setCatalog(catalog);
return previousCatalog;
} catch (SQLException e) {
if (catalog != null) {
try {
c.setCatalog(previousCatalog);
} catch (SQLException ex) {
}
}
throw new SqlException(e);
}
} else {
return null;
}
}
use of org.jumpmind.db.sql.SqlException in project symmetric-ds by JumpMind.
the class AbstractDatabasePlatform method getAlterSymTablePermission.
protected PermissionResult getAlterSymTablePermission(Database database) {
String delimiter = getDatabaseInfo().getDelimiterToken();
delimiter = delimiter != null ? delimiter : "";
Column idColumn = new Column("TEST_ID");
idColumn.setMappedType("INTEGER");
Column valueColumn = new Column("TEST_VALUE");
valueColumn.setMappedType("INTEGER");
Column alterColumn = new Column("TEST_ALTER");
alterColumn.setMappedType("INTEGER");
Table table = new Table(PERMISSION_TEST_TABLE_NAME, idColumn, valueColumn);
Table alterTable = new Table(PERMISSION_TEST_TABLE_NAME, idColumn, valueColumn, alterColumn);
PermissionResult result = new PermissionResult(PermissionType.ALTER_TABLE, Status.FAIL);
try {
database.removeAllTablesExcept();
database.addTable(alterTable);
alterDatabase(database, false);
database.removeAllTablesExcept();
database.addTable(table);
alterDatabase(database, false);
result.setStatus(Status.PASS);
} catch (SqlException e) {
result.setException(e);
result.setSolution("Grant ALTER permission");
}
return result;
}
Aggregations