예제 #1
0
 public void addOrder(Order order) throws Exception {
   PreparedStatement pst = DBUtils.getConnection().prepareStatement(add);
   pst.setInt(1, order.getAddress().getUser().getId());
   pst.setInt(2, order.getStatus());
   pst.setLong(3, order.getTime());
   pst.setDouble(4, order.getTotal());
   pst.setString(5, order.getAddress().getName());
   pst.setString(6, order.getAddress().getAddress());
   pst.setString(7, order.getAddress().getPostalCode());
   pst.setString(8, order.getAddress().getMobile());
   pst.setString(9, order.getAddress().getPhone());
   pst.executeUpdate();
 }
예제 #2
0
 public List<Category> findAll() throws Exception {
   PreparedStatement pst = DBUtils.getConnection().prepareStatement(findAll);
   ResultSet rs = pst.executeQuery();
   List<Category> list = new ArrayList<Category>();
   while (rs.next()) {
     Category cat = new Category();
     cat.setId(rs.getInt("id"));
     cat.setEnName(rs.getString("en_name"));
     cat.setName(rs.getString("name"));
     cat.setTurn(rs.getInt("turn"));
     cat.setDescription(rs.getString("description"));
     cat.setParentId(rs.getInt("parent_id"));
     list.add(cat);
   }
   //		DBUtils.closeConnection();
   return list;
 }