public SInstrument fetchByPK(Integer instrumentId) throws DAOException {
if (instrumentId == null) {
throw new InstrumentDAOException("instrumentId cannot be null");
}
SInstrument instrument = null;
PreparedStatement statement = null;
ResultSet result;
Connection connection = DAOHelper.getDBConnection();
try {
try
{
statement = connection.prepareStatement(FETCHBYPK_QRY);
statement.setInt(1, instrumentId.intValue());
result = statement.executeQuery();
if(result.next())
{
instrument = new SInstrument();
instrument.setObjId(result.getString("id"));
instrument.setObjClass(SInstrument.class.getName());
instrument.setTelescopeId(result.getString("telescope_id"));
instrument.setName(result.getString("name"));
instrument.setDescr(result.getString("description"));
if(result.next())
{
throw new InstrumentDAOException("Multiple rows exists for instrumentId " + instrumentId.toString());
}
}