Пример #1
0
 @Test
 public void selectAll() {
   SqlSession session = null;
   try {
     session = getSession();
     UserDao userDao = session.getMapper(UserDao.class);
     List<Users> users = userDao.selectAll();
     for (Users user : users) {
       System.out.println("username : [" + user.getUsername() + "]");
     }
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     if (session != null) {
       session.close();
     }
   }
 }
Пример #2
0
  @Test
  public void findByUserName() {

    SqlSession session = null;
    try {
      session = getSession();
      UserDao userDao = session.getMapper(UserDao.class);
      Users user = userDao.findByUserName("����+");
      System.out.println("result : [" + String.valueOf(user.getPassword()) + "]");
      session.commit();
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (session != null) {
        session.close();
      }
    }
  }
Пример #3
0
  @Test
  public void update() {
    SqlSession session = null;
    try {
      session = getSession();
      UserDao userDao = session.getMapper(UserDao.class);

      Users user = new Users();
      user.setUsername("����+");
      user.setPassword("22222");
      int result = userDao.update(user);
      System.out.println("result : [" + String.valueOf(result) + "]");
      session.commit();
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (session != null) {
        session.close();
      }
    }
  }