@Override public boolean userLogIn(String email, String password, Connection c) throws SQLException, ClassNotFoundException { String pwd = CryptWithMD5.cryptWithMD5(password); String sql = "select * from user where email='" + email + "' and password='******' "; Statement cs = c.createStatement(); ResultSet eq = cs.executeQuery(sql); return eq.first(); }
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(); }
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(); }
@Override public User user(String email, String password, Connection c) throws SQLException, ClassNotFoundException { String pwd = CryptWithMD5.cryptWithMD5(password); String sql = "select * from user where email='" + email + "' and password='******' "; Statement cs = c.createStatement(); ResultSet eq = cs.executeQuery(sql); User ub = null; if (eq.first()) { ub = new User( eq.getInt(1), eq.getString(2), eq.getString(3), eq.getString(4), eq.getString(5), eq.getString(6), eq.getString(7), eq.getString(8)); } return ub; }