Exemplo n.º 1
0
 public static void main(String[] args) {
   // TODO Auto-generated method stub
   ApplicationContext app = new ClassPathXmlApplicationContext("app.xml");
   MemberDAO dao = (MemberDAO) app.getBean("dao");
   /*Scanner scan=new Scanner(System.in);
   System.out.print("번호:");
   int no=scan.nextInt();
   dao.delete(no);
   System.out.println("삭제 완료");*/
   /*String name=scan.next();
   List<MemberVO> list=dao.memberFindData(name);
   for(MemberVO vo:list)
   {
   	System.out.println(vo.getNo()+" "
   			+vo.getName()+" "
   			+vo.getTel()+" "
   			+vo.getAddr());
   }*/
   MemberVO vo = new MemberVO();
   vo.setNo(2);
   vo.setName("박문식");
   vo.setTel("5555-5555");
   vo.setAddr("제주");
   dao.update(vo);
   System.out.println("데이터 수정 완료");
 }
Exemplo n.º 2
0
  public ArrayList list() {
    ArrayList list = new ArrayList();
    try {
      Connection con = dataFactory.getConnection();
      Statement stmt = con.createStatement();

      String query = "select * from t_member";
      System.out.println(query);
      ResultSet rs = stmt.executeQuery(query);

      while (rs.next()) {
        String id = rs.getString("id");
        String name = rs.getString("name");
        int height = rs.getInt("height");
        int weight = rs.getInt("weight");
        int age = rs.getInt("age");

        MemberVO data = new MemberVO();
        data.setId(id);
        data.setName(name);
        data.setHeight(height);
        data.setWeight(weight);
        data.setAge(age);

        list.add(data);
      }

      rs.close();
      stmt.close();
      con.close();
    } catch (Exception e) {
      e.printStackTrace();
    }

    return list;
  }