* @see org.xooof.xooofoscope.dao.ITelescopeDAO#exist(java.lang.Integer)
*/
public STelescope fetchByPK(Integer telescopeId) throws DAOException {
if (telescopeId == null) {
throw new TelescopeDAOException("telescopeId cannot be null");
}
STelescope telescope = null;
PreparedStatement statement = null;
ResultSet result;
Connection connection = DAOHelper.getDBConnection();
try {
try
{
statement = connection.prepareStatement(FETCHBYPK_QRY);
statement.setInt(1, telescopeId.intValue());
result = statement.executeQuery();
if(result.next())
{
telescope = new STelescope();
telescope.setObjId(result.getString("id"));
telescope.setObjClass(STelescope.class.getName());
telescope.setName(result.getString("name"));
telescope.setDescr(result.getString("description"));
if(result.next())
{
throw new TelescopeDAOException("Multiple rows exists for telescopeId " + telescopeId.toString());
}
}
else {
telescope = null;
}
}
catch(SQLException exc)
{
throw new TelescopeDAOException(exc.getMessage());
}//End catch IOException
}
// This code is to be executed each time in order to release DB Connections
finally
{