Search in sources :

Example 31 with DbException

use of com.axway.ats.core.dbaccess.exceptions.DbException in project ats-framework by Axway.

the class DatabaseOperations method updateValue.

/**
     * Run update query.
     *
     * @param sqlQuery the SQL query to run
     * @return the number of updated rows
     */
@PublicAtsApi
public int updateValue(String sqlQuery) {
    int rowsUpdated;
    try {
        log.debug("Executing update query: '" + sqlQuery + "'");
        rowsUpdated = dbProvider.executeUpdate(sqlQuery);
        if (!(dbProvider instanceof CassandraDbProvider)) {
            if (rowsUpdated == 0) {
                log.warn("SQL query '" + sqlQuery + "' updated 0 rows");
            } else {
                log.debug("SQL query '" + sqlQuery + "' updated '" + rowsUpdated + "' rows");
            }
        }
    } catch (DbException e) {
        throw new DatabaseOperationsException("Error executing update query '" + sqlQuery + "'", e);
    }
    return rowsUpdated;
}
Also used : DatabaseOperationsException(com.axway.ats.action.exceptions.DatabaseOperationsException) CassandraDbProvider(com.axway.ats.core.dbaccess.cassandra.CassandraDbProvider) DbException(com.axway.ats.core.dbaccess.exceptions.DbException) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Aggregations

DbException (com.axway.ats.core.dbaccess.exceptions.DbException)31 SQLException (java.sql.SQLException)11 DbRecordValuesList (com.axway.ats.core.dbaccess.DbRecordValuesList)8 DatabaseOperationsException (com.axway.ats.action.exceptions.DatabaseOperationsException)7 PublicAtsApi (com.axway.ats.common.PublicAtsApi)7 Connection (java.sql.Connection)6 ArrayList (java.util.ArrayList)6 IOException (java.io.IOException)5 PreparedStatement (java.sql.PreparedStatement)5 DbRecordValue (com.axway.ats.core.dbaccess.DbRecordValue)4 DatabaseEnvironmentCleanupException (com.axway.ats.environment.database.exceptions.DatabaseEnvironmentCleanupException)4 BufferedReader (java.io.BufferedReader)4 File (java.io.File)4 FileReader (java.io.FileReader)4 ColumnDescription (com.axway.ats.core.dbaccess.ColumnDescription)3 CassandraDbProvider (com.axway.ats.core.dbaccess.cassandra.CassandraDbProvider)3 ColumnHasNoDefaultValueException (com.axway.ats.environment.database.exceptions.ColumnHasNoDefaultValueException)3 ResultSet (java.sql.ResultSet)3 HashMap (java.util.HashMap)3 DatabaseCell (com.axway.ats.action.dbaccess.model.DatabaseCell)2