@Test public void findUserByUserName() { User user = userDao.findUserByUserName("admin"); assertNotNull(user); assertEquals(user.getUserName(), "admin"); }
public User findUserByUserName(final String userName) { String sqlStr = " SELECT user_id,user_name " + " FROM t_user WHERE user_name =? "; final User user = new User(); jdbcTemplate.query(sqlStr, new Object[]{userName}, new RowCallbackHandler() { public void processRow(ResultSet rs) throws SQLException { user.setUserId(rs.getInt("user_id")); user.setUserName(userName); } }); return user; }
UserDao { public User findUserByUserName(final String userName) { String sqlStr = " SELECT user_id,user_name " + " FROM t_user WHERE user_name =? "; final User user = new User(); jdbcTemplate.query(sqlStr, new Object[]{userName}, new RowCallbackHandler() { public void processRow(ResultSet rs) throws SQLException { user.setUserId(rs.getInt("user_id")); user.setUserName(userName); } }); return user; } }
UserDao { public User findUserByUserName(final String userName) { String sqlStr = " SELECT user_id,user_name " + " FROM t_user WHERE user_name =? "; final User user = new User(); jdbcTemplate.query(sqlStr, new Object[]{userName}, new RowCallbackHandler() { public void processRow(ResultSet rs) throws SQLException { user.setUserId(rs.getInt("user_id")); user.setUserName(userName); } }); return user; }  }
UserDao { public User findUserByUserName(final String userName) { String sqlStr = " SELECT user_id,user_name " + " FROM t_user WHERE user_name =? "; final User user = new User(); jdbcTemplate.query(sqlStr, new Object[]{userName}, new RowCallbackHandler() { public void processRow(ResultSet rs) throws SQLException { user.setUserId(rs.getInt("user_id")); user.setUserName(userName); } }); return user; }  int getMatchCount(String userName, String password); User findUserByUserName(final String userName); void updateLoginInfo(User user); }
UserDao { public User findUserByUserName(final String userName) { String sqlStr = " SELECT user_id,user_name " + " FROM t_user WHERE user_name =? "; final User user = new User(); jdbcTemplate.query(sqlStr, new Object[]{userName}, new RowCallbackHandler() { public void processRow(ResultSet rs) throws SQLException { user.setUserId(rs.getInt("user_id")); user.setUserName(userName); } }); return user; }  int getMatchCount(String userName, String password); User findUserByUserName(final String userName); void updateLoginInfo(User user);  }