Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package persistence;
- import java.sql.SQLException;
- import java.util.List;
- import domain.User;
- import java.sql.Connection;
- import java.sql.ResultSet;
- public class UserMapper implements Mapper<User>
- {
- private User user;
- private SQLConnection con;
- private Connection connection;
- public UserMapper(SQLConnection con)
- {
- this.con = con;
- }
- public UserMapper(){}
- public int getLoginPars(String email, String password) throws SQLException, IllegalStateException, ClassNotFoundException, NullPointerException{
- int intUser = -2;
- int isAdmin = -2;
- String userQuery = "SELECT IsAdminstrator FROM tgamUsers WHERE Email = '"+email+"' AND Password = '"+password+"'";
- ResultSet resultSet = connection.createStatement().executeQuery(userQuery);
- while (resultSet.next()){
- isAdmin = resultSet.getInt("IsAdminstrator");
- }
- if(resultSet == null)
- intUser= -1;
- if(resultSet != null && isAdmin == 0)
- intUser= 0;
- if(resultSet != null && isAdmin == 1)
- intUser= 1;
- return intUser;
- }
- @Override
- public List<User> readAll() throws SQLException, IllegalStateException,
- ClassNotFoundException {
- // TODO Auto-generated method stub
- return null;
- }
- @Override
- public List<User> readItem(Object o) throws SQLException,
- IllegalStateException, ClassNotFoundException {
- // TODO Auto-generated method stub
- return null;
- }
- @Override
- public void update(User e) throws IllegalStateException, SQLException,
- ClassNotFoundException {
- // TODO Auto-generated method stub
- }
- @Override
- public void delete(User item) throws SQLException, IllegalStateException,
- ClassNotFoundException {
- // TODO Auto-generated method stub
- }
- @Override
- public void add(User item) throws SQLException, IllegalStateException,
- ClassNotFoundException {
- // TODO Auto-generated method stub
- }
- }
Add Comment
Please, Sign In to add comment