use of com.axway.ats.core.validation.exceptions.NumberValidationException in project ats-framework by Axway.
the class AbstractDbProvider method rowCount.
/**
* @param tableName the name of the table
* @param whereCondition the where condition ( without the WHERE keyword )
* @return returns the number of the rows that
* match the where statement as a int. Returns 0 if there is
* an error or the rowcount is 0
*/
@Override
public int rowCount(String tableName, String whereCondition) throws DbException, NumberValidationException {
int returnCount;
String sql = " SELECT " + " COUNT(*)" + " FROM " + tableName;
if (whereCondition != null && whereCondition.length() > 0) {
sql += " WHERE " + whereCondition;
}
DbRecordValuesList[] records = select(new DbQuery(sql, new ArrayList<Object>()), DbReturnModes.STRING);
try {
returnCount = records == null ? 0 : Integer.parseInt((String) records[0].get("COUNT(*)"));
} catch (NumberFormatException nfe) {
throw new NumberValidationException("The row count could not be converted to integer", nfe);
}
return returnCount;
}
use of com.axway.ats.core.validation.exceptions.NumberValidationException in project ats-framework by Axway.
the class CassandraDbProvider method rowCount.
@Override
public int rowCount(String tableName, String whereCondition) throws DbException, NumberValidationException {
int returnCount;
String sql = "SELECT " + " COUNT(*)" + " FROM " + tableName;
if (whereCondition != null && whereCondition.length() > 0) {
sql += " WHERE " + whereCondition;
}
DbRecordValuesList[] records = select(new DbQuery(sql, new ArrayList<Object>()), DbReturnModes.STRING);
try {
returnCount = records == null ? 0 : ((Long) records[0].get("count")).intValue();
} catch (NumberFormatException nfe) {
throw new NumberValidationException("The row count could not be converted to integer", nfe);
}
return returnCount;
}
Aggregations