use of org.jumpmind.db.sql.SqlException in project symmetric-ds by JumpMind.
the class AbstractDatabasePlatform method getDropSymTablePermission.
protected PermissionResult getDropSymTablePermission() {
Table table = getPermissionTableDefinition();
PermissionResult result = new PermissionResult(PermissionType.DROP_TABLE, Status.FAIL);
try {
if (getTableFromCache(table.getName(), true) != null) {
dropTables(false, table);
result.setStatus(Status.PASS);
} else {
result.setStatus(Status.NOT_APPLICABLE);
}
} catch (SqlException e) {
result.setException(e);
result.setSolution("Grant DROP permission");
}
return result;
}
use of org.jumpmind.db.sql.SqlException in project symmetric-ds by JumpMind.
the class HsqlDbDatabasePlatform method getCreateSymTriggerPermission.
@Override
public PermissionResult getCreateSymTriggerPermission() {
String delimiter = getDatabaseInfo().getDelimiterToken();
delimiter = delimiter != null ? delimiter : "";
String triggerSql = "CREATE TRIGGER TEST_TRIGGER AFTER UPDATE ON " + delimiter + PERMISSION_TEST_TABLE_NAME + delimiter + " FOR EACH ROW INSERT INTO " + delimiter + PERMISSION_TEST_TABLE_NAME + delimiter + " VALUES(NULL,NULL)";
PermissionResult result = new PermissionResult(PermissionType.CREATE_TRIGGER, Status.FAIL);
try {
getSqlTemplate().update(triggerSql);
result.setStatus(Status.PASS);
} catch (SqlException e) {
result.setException(e);
result.setSolution("Grant CREATE TRIGGER permission or TRIGGER permission");
}
return result;
}
use of org.jumpmind.db.sql.SqlException in project symmetric-ds by JumpMind.
the class InformixDatabasePlatform method getCreateSymTriggerPermission.
@Override
public PermissionResult getCreateSymTriggerPermission() {
String delimiter = getDatabaseInfo().getDelimiterToken();
delimiter = delimiter != null ? delimiter : "";
String triggerSql = "CREATE TRIGGER TEST_TRIGGER DELETE ON " + delimiter + PERMISSION_TEST_TABLE_NAME + delimiter + " FOR EACH ROW(DELETE FROM " + delimiter + PERMISSION_TEST_TABLE_NAME + delimiter + " WHERE TEST_ID IS NULL)";
PermissionResult result = new PermissionResult(PermissionType.CREATE_TRIGGER, Status.FAIL);
try {
getSqlTemplate().update(triggerSql);
result.setStatus(Status.PASS);
} catch (SqlException e) {
result.setException(e);
result.setSolution("Grant CREATE TRIGGER permission or TRIGGER permission");
}
return result;
}
use of org.jumpmind.db.sql.SqlException in project symmetric-ds by JumpMind.
the class AbstractJdbcDdlReader method readTable.
public Table readTable(final String catalog, final String schema, final String table) {
try {
log.debug("reading table: " + table);
JdbcSqlTemplate sqlTemplate = (JdbcSqlTemplate) platform.getSqlTemplate();
return postprocessTableFromDatabase(sqlTemplate.execute(new IConnectionCallback<Table>() {
public Table execute(Connection connection) throws SQLException {
DatabaseMetaDataWrapper metaData = new DatabaseMetaDataWrapper();
metaData.setMetaData(connection.getMetaData());
metaData.setCatalog(catalog);
metaData.setSchemaPattern(schema);
metaData.setTableTypes(null);
ResultSet tableData = null;
try {
log.debug("getting table metadata for " + table);
tableData = metaData.getTables(getTableNamePattern(table));
log.debug("done getting table metadata for " + table);
if (tableData != null && tableData.next()) {
Map<String, Object> values = readMetaData(tableData, initColumnsForTable());
return readTable(connection, metaData, values);
} else {
return null;
}
} finally {
close(tableData);
}
}
}));
} catch (SqlException e) {
if (e.getMessage() != null && StringUtils.containsIgnoreCase(e.getMessage(), "does not exist")) {
return null;
} else {
throw e;
}
}
}
use of org.jumpmind.db.sql.SqlException in project symmetric-ds by JumpMind.
the class AbstractJdbcDdlReader method initWildcardString.
protected void initWildcardString(IDatabasePlatform platform) {
DataSource ds = platform.getDataSource();
Connection c = null;
try {
c = ds.getConnection();
wildcardEscapeString = c.getMetaData().getSearchStringEscape();
} catch (SQLException ex) {
throw new SqlException(ex);
} finally {
JdbcSqlTemplate.close(c);
}
}
Aggregations