コード例 #1
0
 public int add(User e, Connection c) throws SQLException {
   String sql = "insert into User values(?,?,?,?,?,?,?,?)";
   PreparedStatement ps = c.prepareStatement(sql);
   String pwdencrypt = CryptWithMD5.cryptWithMD5(e.getPassword());
   Object userDetails[] = {
     e.getId(),
     e.getUsername(),
     e.getPassword(),
     e.getFirst_name(),
     e.getLast_name(),
     e.getEmail(),
     e.getSex()
   };
   for (int i = 0; i < userDetails.length; i++) {
     ps.setObject(i + 1, userDetails[i]);
   }
   return ps.executeUpdate();
 }
コード例 #2
0
 public int updte(User e, Connection c) throws SQLException {
   String sql =
       "update user set firstName=? , lastName=? , age=? , sex=? , weight=? , height=? , waistSize=? , occupation=? , workinghours=? , anydiseases=? , takingmedicines=? , userName=? , email=? , password=? , photopathofuser=? where userid=?";
   PreparedStatement ps = c.prepareStatement(sql);
   String pwdencrypt = CryptWithMD5.cryptWithMD5(e.getPassword());
   Object upd[] = {
     e.getId(),
     e.getUsername(),
     e.getPassword(),
     e.getFirst_name(),
     e.getLast_name(),
     e.getEmail(),
     e.getSex()
   };
   for (int i = 0; i < upd.length; i++) {
     ps.setObject(i + 1, upd[i]);
   }
   return ps.executeUpdate();
 }