Guest User

Untitled

a guest
Jul 6th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. package persistence;
  2.  
  3. import java.sql.SQLException;
  4. import java.util.List;
  5. import domain.User;
  6. import java.sql.Connection;
  7. import java.sql.ResultSet;
  8.  
  9. public class UserMapper implements Mapper<User>
  10. {
  11. private User user;
  12. private SQLConnection con;
  13. private Connection connection;
  14.  
  15. public UserMapper(SQLConnection con)
  16. {
  17. this.con = con;
  18. }
  19. public UserMapper(){}
  20.  
  21. public int getLoginPars(String email, String password) throws SQLException, IllegalStateException, ClassNotFoundException, NullPointerException{
  22. int intUser = -2;
  23. int isAdmin = -2;
  24. String userQuery = "SELECT IsAdminstrator FROM tgamUsers WHERE Email = '"+email+"' AND Password = '"+password+"'";
  25. ResultSet resultSet = connection.createStatement().executeQuery(userQuery);
  26. while (resultSet.next()){
  27. isAdmin = resultSet.getInt("IsAdminstrator");
  28.  
  29. }
  30. if(resultSet == null)
  31. intUser= -1;
  32. if(resultSet != null && isAdmin == 0)
  33. intUser= 0;
  34. if(resultSet != null && isAdmin == 1)
  35. intUser= 1;
  36. return intUser;
  37. }
  38.  
  39.  
  40. @Override
  41. public List<User> readAll() throws SQLException, IllegalStateException,
  42. ClassNotFoundException {
  43. // TODO Auto-generated method stub
  44. return null;
  45. }
  46.  
  47. @Override
  48. public List<User> readItem(Object o) throws SQLException,
  49. IllegalStateException, ClassNotFoundException {
  50. // TODO Auto-generated method stub
  51. return null;
  52. }
  53.  
  54. @Override
  55. public void update(User e) throws IllegalStateException, SQLException,
  56. ClassNotFoundException {
  57. // TODO Auto-generated method stub
  58.  
  59. }
  60.  
  61. @Override
  62. public void delete(User item) throws SQLException, IllegalStateException,
  63. ClassNotFoundException {
  64. // TODO Auto-generated method stub
  65.  
  66. }
  67.  
  68. @Override
  69. public void add(User item) throws SQLException, IllegalStateException,
  70. ClassNotFoundException {
  71. // TODO Auto-generated method stub
  72.  
  73. }
  74.  
  75. }
Add Comment
Please, Sign In to add comment