Пример #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
 User resultSetToEntity(ResultSet res) throws SQLException {
   User u = new User();
   u.setId(res.getInt("id"));
   u.setName(res.getString("name"));
   u.setFbid(res.getString("fbID"));
   u.setLastIP(res.getString("lastIP"));
   u.setLastDate(res.getDate("lastDate"));
   u.setRegDate(res.getDate("regDate"));
   return u;
 }
Пример #3
0
 public boolean delete(User u) {
   String sql = "DELETE FROM member WHERE memberID=?";
   try {
     PreparedStatement ps = conn.prepareStatement(sql);
     ps.setInt(1, u.getId());
     boolean b = ps.execute();
     ps.close();
     return b;
   } catch (SQLException e) {
     e.printStackTrace();
   }
   return false;
 }
Пример #4
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;
 }