示例#1
0
 public boolean update(User u) {
   String sql = "UPDATE member SET name=?, lastIP=?, lastDate=? WHERE id=?";
   try {
     PreparedStatement ps = conn.prepareStatement(sql);
     ps.setString(1, u.getName());
     ps.setString(2, u.getLastIP());
     ps.setDate(3, new java.sql.Date(u.getLastDate().getTime()));
     ps.setInt(4, u.getId());
     boolean b = ps.execute();
     ps.close();
     return b;
   } catch (SQLException e) {
     e.printStackTrace();
   }
   return false;
 }
示例#2
0
 public boolean insert(User u) {
   String sql =
       "INSERT INTO member (id, name, fbID, lastIP, lastDate, regDate) VALUES ( ?, ?, ?, ?, ?, ?)";
   try {
     PreparedStatement ps = conn.prepareStatement(sql);
     ps.setInt(1, u.getId());
     ps.setString(2, u.getName());
     ps.setString(3, u.getFbid());
     ps.setString(4, u.getLastIP());
     ps.setDate(5, new java.sql.Date(u.getLastDate().getTime()));
     ps.setDate(6, new java.sql.Date(u.getRegDate().getTime()));
     boolean b = ps.execute();
     ps.close();
     return b;
   } catch (SQLException e) {
     e.printStackTrace();
   }
   return false;
 }