use of com.axway.ats.core.dbaccess.exceptions.DbRecordsException in project ats-framework by Axway.
the class AbstractDbProvider method selectValue.
public InputStream selectValue(String tableName, String[] keyColumns, String[] keyValues, String queryColumn, int recordNumber) throws DbException, ValidationException {
InputStream queryValueStream = null;
//all operands are "equals"
String[] whereOperands = new String[keyColumns.length];
for (int i = 0; i < whereOperands.length; i++) {
whereOperands[i] = "=";
}
String sql = constructSelectStatement(new String[] { queryColumn }, tableName, keyColumns, keyValues, whereOperands);
DbRecordValuesList[] records = select(new DbQuery(sql, new ArrayList<Object>()), DbReturnModes.INPUT_STREAM);
if (records == null) {
throw new DbRecordsException();
}
if (records.length < recordNumber + 1) {
throw new DbRecordsException(records.length, recordNumber + 1);
} else {
queryValueStream = (InputStream) records[recordNumber].get(queryColumn);
}
return queryValueStream;
}
use of com.axway.ats.core.dbaccess.exceptions.DbRecordsException in project ats-framework by Axway.
the class AbstractDbProvider method selectValue.
public InputStream selectValue(String tableName, String keyColumn, String keyValue, String queryColumn, int recordNumber) throws DbException {
InputStream queryValueStream = null;
String sql = " SELECT " + queryColumn + " FROM " + tableName + " WHERE " + keyColumn + " = '" + escapeSql(keyValue) + "'";
DbRecordValuesList[] records = select(new DbQuery(sql, new ArrayList<Object>()), DbReturnModes.INPUT_STREAM);
if (records == null) {
throw new DbRecordsException();
}
if (records.length < recordNumber + 1) {
throw new DbRecordsException(records.length, recordNumber + 1);
}
queryValueStream = (InputStream) records[recordNumber].get(queryColumn);
return queryValueStream;
}
use of com.axway.ats.core.dbaccess.exceptions.DbRecordsException in project ats-framework by Axway.
the class PackageLoader method loadPackageFromDb.
private static InputStream loadPackageFromDb(int packageId, String messagesHost, String messagesDB, String messagestable, String messagesUser, String messagesPassword) throws PackageException {
DbConnMySQL dbConnection = new DbConnMySQL(messagesHost, messagesDB, messagesUser, messagesPassword);
MysqlDbProvider dbProvider = new MysqlDbProvider(dbConnection);
try {
InputStream packageContent = dbProvider.selectValue(messagestable, "message_id", Integer.toString(packageId), "data");
log.info("Successfully extracted package with id '" + packageId + "' from '" + messagestable + "' DB");
return packageContent;
} catch (DbRecordsException dbre) {
throw new PackageException("Package with id '" + packageId + "' does not exist in 'messages' DB");
} catch (DbException dbe) {
throw new PackageException("Could not get package with id '" + packageId + "' from the 'messages' DB");
}
}
Aggregations