SHARE
TWEET

a

a guest Apr 27th, 2018 145 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package login;
  2.  
  3. import javax.inject.Named;
  4. import javax.enterprise.context.SessionScoped;
  5. import java.io.Serializable;
  6. import java.sql.Connection;
  7. import java.sql.DriverManager;
  8. import java.sql.ResultSet;
  9. import java.sql.SQLException;
  10. import java.sql.Statement;
  11. import javax.faces.context.FacesContext;
  12. import javax.servlet.http.HttpSession;
  13.  
  14. @Named(value = "variable")
  15. @SessionScoped
  16. public class Variable implements Serializable {
  17.  
  18.     public Variable() {
  19.  
  20.     }
  21.     String GetsUsername, GetsPassword;
  22.     public static String Name;
  23.  
  24.     public String getGetsUsername() {
  25.         return GetsUsername;
  26.     }
  27.  
  28.     public void setGetsUsername(String GetsUsername) {
  29.         this.GetsUsername = GetsUsername;
  30.     }
  31.  
  32.     public String getGetsPassword() {
  33.         return GetsPassword;
  34.     }
  35.  
  36.     public void setGetsPassword(String GetsPassword) {
  37.         this.GetsPassword = GetsPassword;
  38.     }
  39.     //User DB
  40.     String ID,
  41.             username,
  42.             Email,
  43.             password,
  44.             State,
  45.             Comment,
  46.             Notification,
  47.             Mail,
  48.             Notes,
  49.             Age,
  50.             Friend,
  51.             Avatar;
  52.  
  53.     public boolean load() {
  54.         Name = "";
  55.         try {
  56.             Class.forName("com.mysql.jdbc.Driver").newInstance();
  57.             Connection MC = DriverManager.getConnection("jdbc:mysql://localhost/test", "root", "1234");
  58.             Statement STF = MC.createStatement();
  59.             ResultSet R = STF.executeQuery("Select * from user");
  60.             while (R.next()) {
  61.                 username = (R.getString("Name"));
  62.                 password = (R.getString("Password"));
  63.                 if (GetsUsername.equals(username) && GetsPassword.equals(password)) {
  64.                     Name = username;
  65.                     return true;
  66.                 }
  67.             }
  68.         } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | SQLException E) {
  69.             System.out.println(E);
  70.         }
  71.         return false;
  72.  
  73.     }
  74.  
  75.     public String check() {
  76.         if (load()) {
  77.             return "MyPosts.xhtml?faces-redirect=true";
  78.         } else {
  79.             return "login.xhtml?faces-redirect=true";
  80.         }
  81.     }
  82.  
  83.     public String logout()
  84.     {
  85.         Name = "";
  86.         return "login.xhtml";
  87.     }
  88.  
  89.     public String getID() {
  90.         return ID;
  91.     }
  92.  
  93.     public void setID(String ID) {
  94.         this.ID = ID;
  95.     }
  96.  
  97.     public String getUsername() {
  98.         return username;
  99.     }
  100.  
  101.     public void setUsername(String username) {
  102.         this.username = username;
  103.     }
  104.  
  105.     public String getEmail() {
  106.         return Email;
  107.     }
  108.  
  109.     public void setEmail(String Email) {
  110.         this.Email = Email;
  111.     }
  112.  
  113.     public String getPassword() {
  114.         return password;
  115.     }
  116.  
  117.     public void setPassword(String password) {
  118.         this.password = password;
  119.     }
  120.  
  121.     public String getState() {
  122.         return State;
  123.     }
  124.  
  125.     public void setState(String State) {
  126.         this.State = State;
  127.     }
  128.  
  129.     public String getComment() {
  130.         return Comment;
  131.     }
  132.  
  133.     public void setComment(String Comment) {
  134.         this.Comment = Comment;
  135.     }
  136.  
  137.     public String getNotification() {
  138.         return Notification;
  139.     }
  140.  
  141.     public void setNotification(String Notification) {
  142.         this.Notification = Notification;
  143.     }
  144.  
  145.     public String getMail() {
  146.         return Mail;
  147.     }
  148.  
  149.     public void setMail(String Mail) {
  150.         this.Mail = Mail;
  151.     }
  152.  
  153.     public String getNotes() {
  154.         return Notes;
  155.     }
  156.  
  157.     public void setNotes(String Notes) {
  158.         this.Notes = Notes;
  159.     }
  160.  
  161.     public String getAge() {
  162.         return Age;
  163.     }
  164.  
  165.     public void setAge(String Age) {
  166.         this.Age = Age;
  167.     }
  168.  
  169.     public String getFriend() {
  170.         return Friend;
  171.     }
  172.  
  173.     public void setFriend(String Friend) {
  174.         this.Friend = Friend;
  175.     }
  176.  
  177.     public String getAvatar() {
  178.         return Avatar;
  179.     }
  180.  
  181.     public void setAvatar(String Avatar) {
  182.         this.Avatar = Avatar;
  183.     }
  184.  
  185. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top