use of org.cerberus.engine.entity.MessageGeneral in project cerberus-source by cerberustesting.
the class SqlLibraryDAO method updateSqlLibrary.
@Override
public void updateSqlLibrary(String name, String columnName, String value) throws CerberusException {
boolean throwExcep = false;
StringBuilder query = new StringBuilder();
query.append("update sqllibrary set `");
query.append(columnName);
query.append("`=? where `name`=? ");
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query.toString());
try {
preStat.setString(1, value);
preStat.setString(2, name);
preStat.executeUpdate();
throwExcep = false;
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
preStat.close();
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException e) {
LOG.warn(e.toString());
}
}
if (throwExcep) {
throw new CerberusException(new MessageGeneral(MessageGeneralEnum.CANNOT_UPDATE_TABLE));
}
}
use of org.cerberus.engine.entity.MessageGeneral in project cerberus-source by cerberustesting.
the class SqlLibraryDAO method updateSqlLibrary.
@Override
public void updateSqlLibrary(SqlLibrary sqlLibrary) throws CerberusException {
boolean throwExcep = false;
StringBuilder query = new StringBuilder();
query.append("update sqllibrary set `script`=?,`description`=?, `type`=?, `database`=? where `name`=? ");
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query.toString());
try {
preStat.setString(1, sqlLibrary.getScript());
preStat.setString(2, sqlLibrary.getDescription());
preStat.setString(3, sqlLibrary.getType());
preStat.setString(4, sqlLibrary.getDatabase());
preStat.setString(5, sqlLibrary.getName());
preStat.executeUpdate();
throwExcep = false;
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
preStat.close();
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException e) {
LOG.warn(e.toString());
}
}
if (throwExcep) {
throw new CerberusException(new MessageGeneral(MessageGeneralEnum.CANNOT_UPDATE_TABLE));
}
}
use of org.cerberus.engine.entity.MessageGeneral in project cerberus-source by cerberustesting.
the class TestCaseCountryDAO method deleteTestCaseCountry.
@Override
public void deleteTestCaseCountry(TestCaseCountry tcc) throws CerberusException {
boolean throwExcep = false;
final String query = "DELETE FROM testcasecountry WHERE test = ? and testcase = ? and country = ?";
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query);
try {
preStat.setString(1, tcc.getTest());
preStat.setString(2, tcc.getTestCase());
preStat.setString(3, tcc.getCountry());
throwExcep = preStat.executeUpdate() == 0;
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
preStat.close();
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException e) {
LOG.warn(e.toString());
}
}
if (throwExcep) {
throw new CerberusException(new MessageGeneral(MessageGeneralEnum.CANNOT_UPDATE_TABLE));
}
}
use of org.cerberus.engine.entity.MessageGeneral in project cerberus-source by cerberustesting.
the class UserSystemDAO method insertUserSystem.
@Override
public void insertUserSystem(UserSystem userSystem) throws CerberusException {
final String query = "INSERT INTO usersystem (`login`, `system`) VALUES (?, ?)";
try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query)) {
try {
preStat.setString(1, userSystem.getLogin());
preStat.setString(2, userSystem.getSystem());
preStat.execute();
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
throw new CerberusException(new MessageGeneral(MessageGeneralEnum.CANNOT_UPDATE_TABLE));
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
throw new CerberusException(new MessageGeneral(MessageGeneralEnum.CANNOT_UPDATE_TABLE));
}
}
use of org.cerberus.engine.entity.MessageGeneral in project cerberus-source by cerberustesting.
the class UserSystemDAO method deleteUserSystem.
@Override
public void deleteUserSystem(UserSystem userSystem) throws CerberusException {
final String query = "DELETE FROM usersystem WHERE `login` = ? and `system` = ?";
try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query)) {
try {
preStat.setString(1, userSystem.getLogin());
preStat.setString(2, userSystem.getSystem());
preStat.execute();
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
throw new CerberusException(new MessageGeneral(MessageGeneralEnum.CANNOT_UPDATE_TABLE));
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
throw new CerberusException(new MessageGeneral(MessageGeneralEnum.CANNOT_UPDATE_TABLE));
}
}
Aggregations