Пример #1
0
 @Override
 public UserInfo findUser(int id) {
   // TODO Auto-generated method stub
   UserInfo user = null;
   String sql = "select * from userinfo where userId=?";
   try {
     conn = this.getConn();
     pstmt = conn.prepareStatement(sql);
     pstmt.setInt(1, id);
     rs = pstmt.executeQuery();
     while (rs.next()) {
       user = new UserInfo();
       user.setUserId(rs.getInt("userId"));
       user.setId(rs.getInt("id"));
       user.setUserName(rs.getString("userName"));
       user.setUserPwd(rs.getString("userPwd"));
       user.setName(rs.getString("name"));
       user.setUserSex(rs.getString("userSex"));
       user.setUserLinkMan(rs.getString("userLinkMan"));
       user.setUserEmail(rs.getString("userEmail"));
       user.setUserTel(rs.getString("userTel"));
       user.setUserUnit(rs.getString("userUnit"));
       user.setUserUrl(rs.getString("userUrl"));
       user.setUserCountry(rs.getString("userCountry"));
       user.setUserProvince(rs.getString("userProvince"));
       user.setUserCity(rs.getString("userCity"));
       user.setUserPost(rs.getString("userPost"));
       user.setUserAddress(rs.getString("userAddress"));
       user.setUserProduct(rs.getString("userProduct"));
       user.setUserProductType(rs.getString("userProductType"));
       user.setUserProductId(rs.getString("userProductId"));
       user.setHead(rs.getString("head"));
       user.setRegTime(rs.getString("regTime"));
     }
   } catch (Exception e) {
     // TODO: handle exception
     System.out.println("findUser方法异常通过用户id查找");
     e.printStackTrace();
   } finally {
     this.closeAll(conn, pstmt, rs);
   }
   return user;
 }
Пример #2
0
 public int updateUser(UserInfo user) {
   // TODO Auto-generated method stub
   String sql = "update userinfo set userPwd=? where userName=?";
   String[] getValue = {user.getUserPwd(), user.getUserName()};
   return this.executeSQL(sql, getValue);
 }