use of org.jumpmind.db.sql.SqlException in project symmetric-ds by JumpMind.
the class MySqlDatabasePlatform 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 MySqlDatabasePlatform method getCreateSymRoutinePermission.
@Override
public PermissionResult getCreateSymRoutinePermission() {
String routineSql = "CREATE PROCEDURE TEST_PROC() BEGIN SELECT 1; END";
String dropSql = "DROP PROCEDURE IF EXISTS TEST_PROC";
PermissionResult result = new PermissionResult(PermissionType.CREATE_ROUTINE, Status.FAIL);
try {
getSqlTemplate().update(dropSql);
getSqlTemplate().update(routineSql);
result.setStatus(Status.PASS);
getSqlTemplate().update(dropSql);
} catch (SqlException e) {
result.setException(e);
result.setSolution("Grant CREATE ROUTINE Privilege");
}
return result;
}
use of org.jumpmind.db.sql.SqlException in project symmetric-ds by JumpMind.
the class H2DatabasePlatform 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 CALL " + delimiter + "org.jumpmind.db.platform.h2.H2TestTrigger" + delimiter;
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 OracleDatabasePlatform method getCreateSymTriggerPermission.
@Override
public PermissionResult getCreateSymTriggerPermission() {
String delimiter = getDatabaseInfo().getDelimiterToken();
delimiter = delimiter != null ? delimiter : "";
String triggerSql = "CREATE OR REPLACE TRIGGER TEST_TRIGGER AFTER UPDATE ON " + delimiter + PERMISSION_TEST_TABLE_NAME + delimiter + " BEGIN END";
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 JdbcDatabasePlatformFactory method getDatabaseProductVersion.
public static String getDatabaseProductVersion(DataSource dataSource) {
Connection connection = null;
try {
connection = dataSource.getConnection();
DatabaseMetaData metaData = connection.getMetaData();
return metaData.getDatabaseProductVersion();
} catch (SQLException ex) {
throw new SqlException("Error while reading the database metadata: " + ex.getMessage(), ex);
} finally {
if (connection != null) {
try {
connection.close();
} catch (SQLException ex) {
// we ignore this one
}
}
}
}
Aggregations