コード例 #1
0
 public OrigenBO queryOrigenById(String _idOrigen) throws DAOException {
   OrigenBO origen = null;
   Connection conn = null;
   PreparedStatement stmt = null;
   ResultSet rs = null;
   String sql = "select o.ID, o.NOMBRE from ORIGENES o where o.ID = ?";
   try {
     conn = OracleDAOFactory.createConnection(config.get(EnvioNominasConfig.JNDI_DATASOURCE));
     stmt = conn.prepareStatement(sql);
     stmt.setString(1, _idOrigen);
     rs = stmt.executeQuery();
     while (rs.next()) {
       origen = new OrigenBO();
       origen.setCodigo(rs.getString("ID"));
       origen.setNombre(rs.getString("NOMBRE"));
     }
   } catch (RuntimeException e) {
     throw new DAOException("Error en la consulta : [" + e.getMessage() + "][" + sql + "]", e);
   } catch (DAOException e) {
     throw e;
   } catch (SQLException e) {
     throw new DAOException("Error en la consulta : [" + e.getMessage() + "][" + sql + "]", e);
   } finally {
     OracleDAOFactory.closeAll(conn, stmt, rs);
   }
   return origen;
 }
コード例 #2
0
 public List<OrigenBO> queryOrigenes() throws DAOException {
   List<OrigenBO> origenes = new ArrayList<OrigenBO>();
   Connection conn = null;
   Statement stmt = null;
   ResultSet rs = null;
   String sql = "select o.ID, o.NOMBRE from ORIGENES o";
   try {
     conn = OracleDAOFactory.createConnection(config.get(EnvioNominasConfig.JNDI_DATASOURCE));
     stmt = conn.createStatement();
     rs = stmt.executeQuery(sql);
     while (rs.next()) {
       OrigenBO origen = new OrigenBO();
       origen.setCodigo(rs.getString("ID"));
       origen.setNombre(rs.getString("NOMBRE"));
       origenes.add(origen);
     }
   } catch (RuntimeException e) {
     throw new DAOException("Error en la consulta : [" + e.getMessage() + "][" + sql + "]", e);
   } catch (DAOException e) {
     throw e;
   } catch (SQLException e) {
     throw new DAOException("Error en la consulta : [" + e.getMessage() + "][" + sql + "]", e);
   } finally {
     OracleDAOFactory.closeAll(conn, stmt, rs);
   }
   return origenes;
 }