use of cn.edu.zju.acm.onlinejudge.bean.Configuration in project zoj by licheng.
the class ConfigurationPersistenceImpl method getConfigurations.
/**
* <p>
* Returns a list of Configuration instances retrieved from persistence layer.
* </p>
*
* @return a list of Configuration instances retrieved from persistence layer.
* @throws PersistenceException
* wrapping a persistence implementation specific exception
*/
public List<Configuration> getConfigurations() throws PersistenceException {
Connection conn = null;
try {
conn = Database.createConnection();
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(ConfigurationPersistenceImpl.GET_ALL_CONFIGURATIONS);
ResultSet rs = ps.executeQuery();
List<Configuration> configurations = new ArrayList<Configuration>();
while (rs.next()) {
Configuration configuration = new Configuration();
configuration.setName(rs.getString(DatabaseConstants.CONFIGURATION_NAME));
configuration.setValue(rs.getString(DatabaseConstants.CONFIGURATION_VALUE));
configuration.setDescription(rs.getString(DatabaseConstants.CONFIGURATION_DESCRIPTION));
configurations.add(configuration);
}
return configurations;
} finally {
Database.dispose(ps);
}
} catch (SQLException e) {
throw new PersistenceException("Error.", e);
} finally {
Database.dispose(conn);
}
}
Aggregations