Package org.xooof.xooofoscope.dao.exception

Examples of org.xooof.xooofoscope.dao.exception.InstrumentDAOException


 
  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());
        }
      }
      else {    
        instrument = null;
      }
      }
      catch(SQLException exc)
      {
        throw new InstrumentDAOException(exc.getMessage());
      }//End catch IOException
    }
    // This code is to be executed each time in order to release DB Connections
    finally
    {
View Full Code Here


  }

  public SInstrumentArrayList fetchByTelescopeId(Integer telescopeId) throws DAOException {

    if (telescopeId == null) {
      throw new InstrumentDAOException("telescopeId cannot be null");
    }
    SInstrumentArrayList instrumentList = new SInstrumentArrayList();
    SInstrument instrument = null;
    PreparedStatement statement = null;
    ResultSet result;   
    Connection connection = DAOHelper.getDBConnection();   
    try {   
      try
      {
      statement = connection.prepareStatement(FETCHBYTELESCOPE_QRY);
      statement.setInt(1, telescopeId.intValue());
      result = statement.executeQuery();
      while(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"));
        instrumentList.add(instrument);
      }
      }
      catch(SQLException exc)
      {
        throw new InstrumentDAOException(exc.getMessage());
      }//End catch IOException
    }
    // This code is to be executed each time in order to release DB Connections
    finally
    {
View Full Code Here

        instrumentList.add(instrument);
      }
      }
      catch(SQLException exc)
      {
        throw new InstrumentDAOException(exc.getMessage());
      }//End catch IOException
    }
    // This code is to be executed each time in order to release DB Connections
    finally
    {
View Full Code Here

TOP

Related Classes of org.xooof.xooofoscope.dao.exception.InstrumentDAOException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.