public User mapRow(ResultSet rs, int i) throws SQLException { User user = new User(); user.setId(rs.getString("id")); user.setName(rs.getString("name")); user.setPassword(rs.getString("password")); return user; }
public User mapRow(ResultSet rs, int rowNum) throws SQLException { User user = new User(); user.setId(rs.getString("id")); user.setName(rs.getString("name")); user.setPassword(rs.getString("password")); user.setLevel(Level.valueOf(rs.getInt("level"))); user.setLogin(rs.getInt("login")); user.setRecommend(rs.getInt("recommend")); user.setEmail(rs.getString("email")); return user; }
public static void main(String[] args) throws ClassNotFoundException, SQLException { ApplicationContext context = new GenericXmlApplicationContext("applicationContext.xml"); // ApplicationContext context = new AnnotationConfigApplicationContext(DaoFactory.class); UserDaoJdbc dao = context.getBean("userDao", UserDaoJdbc.class); User user = new User(); user.setId("whiteship2"); user.setName("백기선2"); user.setPassword("married"); dao.add(user); System.out.println(user.getId() + "등록성공"); User user2 = dao.get(user.getId()); if (!user.getName().equals(user2.getName())) { System.out.println("테스트 실패 (name)"); } else if (!user.getPassword().equals(user2.getPassword())) { System.out.println("테스트 실패 (password)"); } else { System.out.println("조회 테스트 성공"); } }