Пример #1
0
 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"));
   return user;
 }
Пример #2
0
 public int update(User user) {
   return this.jdbcTemplate.update(
       "update users set name = ?,"
           + " password = ?, level = ?, login = ?, recommend = ?"
           + " where id = ?",
       user.getName(),
       user.getPassword(),
       user.getLevel().intValue(),
       user.getLogin(),
       user.getRecommend(),
       user.getId());
 }
Пример #3
0
 public void add(final User user) {
   System.out.println(
       user.getId()
           + ","
           + user.getName()
           + ","
           + user.getPassword()
           + ","
           + user.getLevel().intValue()
           + ","
           + user.getLogin()
           + ","
           + user.getRecommend());
   this.jdbcTemplate.update(
       "insert into users(id, name, password, level, login, recommend) values(?, ?, ?, ?, ?, ?) ",
       user.getId(),
       user.getName(),
       user.getPassword(),
       user.getLevel().intValue(),
       user.getLogin(),
       user.getRecommend());
 }