Search in sources :

Example 1 with Machine

use of com.axway.ats.log.autodb.entities.Machine in project ats-framework by Axway.

the class DbReadAccess method getMachines.

public List<Machine> getMachines() throws DatabaseAccessException {
    List<Machine> machines = new ArrayList<Machine>();
    Connection connection = getConnection();
    PreparedStatement statement = null;
    ResultSet rs = null;
    try {
        statement = connection.prepareStatement("SELECT * FROM tMachines ORDER BY machineName");
        rs = statement.executeQuery();
        while (rs.next()) {
            Machine machine = new Machine();
            machine.machineId = rs.getInt("machineId");
            machine.name = rs.getString("machineName");
            machine.alias = rs.getString("machineAlias");
            machines.add(machine);
        }
    } catch (Exception e) {
        throw new DatabaseAccessException("Error retrieving machines", e);
    } finally {
        DbUtils.closeResultSet(rs);
        DbUtils.close(connection, statement);
    }
    return machines;
}
Also used : ArrayList(java.util.ArrayList) Connection(java.sql.Connection) DbConnection(com.axway.ats.core.dbaccess.DbConnection) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) Machine(com.axway.ats.log.autodb.entities.Machine) SQLException(java.sql.SQLException) DatabaseAccessException(com.axway.ats.log.autodb.exceptions.DatabaseAccessException) DatabaseAccessException(com.axway.ats.log.autodb.exceptions.DatabaseAccessException)

Aggregations

DbConnection (com.axway.ats.core.dbaccess.DbConnection)1 Machine (com.axway.ats.log.autodb.entities.Machine)1 DatabaseAccessException (com.axway.ats.log.autodb.exceptions.DatabaseAccessException)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1