Exemplo n.º 1
0
 public List<Unit> findAllUnit() {
   String sql = "select * from Unit";
   OracleCachedRowSet ocrs = DbOperation.executeQuery(sql, null);
   List<Unit> list = new ArrayList<Unit>();
   try {
     while (ocrs.next()) {
       Unit unit = new Unit(ocrs.getString(1), ocrs.getDouble(2));
       list.add(unit);
     }
     if (!list.isEmpty()) {
       return list;
     } else {
       return null;
     }
   } catch (SQLException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } finally {
     try {
       ocrs.close();
     } catch (SQLException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
   return null;
 }
Exemplo n.º 2
0
 public Unit findByUnit(String unitId) {
   String sql = "select * from Unit where unit = ?";
   Object[] objects = new Object[] {unitId};
   OracleCachedRowSet ocrs = DbOperation.executeQuery(sql, objects);
   Unit unit = null;
   try {
     if (ocrs.next()) {
       unit = new Unit(ocrs.getString(1), ocrs.getDouble(2));
     }
     return unit;
   } catch (SQLException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } finally {
     try {
       ocrs.close();
     } catch (SQLException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
   return null;
 }
Exemplo n.º 3
0
 public List<Goods> findAllGoods() {
   String sql = "select * from Goods";
   OracleCachedRowSet ocrs = DbOperation.executeQuery(sql, null);
   List<Goods> list = new ArrayList<Goods>();
   try {
     while (ocrs.next()) {
       Goods goods =
           new Goods(
               ocrs.getString(1), ocrs.getString(2),
               ocrs.getString(3), ocrs.getString(4),
               ocrs.getString(5), ocrs.getString(6),
               ocrs.getString(7), ocrs.getString(8),
               ocrs.getString(9), ocrs.getString(10),
               ocrs.getString(11), ocrs.getDouble(12),
               ocrs.getDouble(13), ocrs.getDouble(14));
       list.add(goods);
     }
     if (!list.isEmpty()) {
       return list;
     } else {
       return null;
     }
   } catch (SQLException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } finally {
     try {
       ocrs.close();
     } catch (SQLException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
   return null;
 }
Exemplo n.º 4
0
 public Goods findById(String goodsId) {
   String sql = "select * from Goods where goodsId = ?";
   Object[] objects = new Object[] {goodsId};
   OracleCachedRowSet ocrs = DbOperation.executeQuery(sql, objects);
   Goods goods = null;
   try {
     if (ocrs.next()) {
       goods =
           new Goods(
               ocrs.getString(1), ocrs.getString(2),
               ocrs.getString(3), ocrs.getString(4),
               ocrs.getString(5), ocrs.getString(6),
               ocrs.getString(7), ocrs.getString(8),
               ocrs.getString(9), ocrs.getString(10),
               ocrs.getString(11), ocrs.getDouble(12),
               ocrs.getDouble(13), ocrs.getDouble(14));
     }
     return goods;
   } catch (SQLException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } finally {
     try {
       ocrs.close();
     } catch (SQLException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
   return null;
 }
Exemplo n.º 5
0
 public List<Goods> findByPage(PageBean pageBean) {
   String sql =
       "select * from (select gods.* ,rownum rn from (select * from Goods order by goodsId asc )gods where rownum <=?) where rn>=?";
   List<Goods> list = new ArrayList<Goods>();
   Object[] objects =
       new Object[] {
         PageBean.pageSize * pageBean.getCurrentPage(),
         PageBean.pageSize * (pageBean.getCurrentPage() - 1) + 1
       };
   OracleCachedRowSet ocrs = DbOperation.executeQuery(sql, objects);
   try {
     while (ocrs.next()) {
       Goods goods =
           new Goods(
               ocrs.getString(1), ocrs.getString(2),
               ocrs.getString(3), ocrs.getString(4),
               ocrs.getString(5), ocrs.getString(6),
               ocrs.getString(7), ocrs.getString(8),
               ocrs.getString(9), ocrs.getString(10),
               ocrs.getString(11), ocrs.getDouble(12),
               ocrs.getDouble(13), ocrs.getDouble(14));
       list.add(goods);
     }
     if (!list.isEmpty()) {
       return list;
     } else {
       return null;
     }
   } catch (SQLException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } finally {
     try {
       ocrs.close();
     } catch (SQLException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
   return null;
 }