Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String url = "jdbc:mysql://localhost:3306/";
- String dbName = "myDatabase";
- String driver = "com.mysql.jdbc.Driver";
- String userName = "root";
- String password = "candy";
- String userNameE = jTextField1.getText();
- String passwordE = new String(jPasswordField1.getPassword());
- String passwordF;
- // String passwordCheck = null;
- String userNameCheck = null;
- boolean loginFail = true;
- Connection con = null;
- try {
- con = DriverManager.getConnection(url+dbName,userName,password);
- System.out.println("Connected to the database");
- Statement st = con.createStatement();
- ResultSet rt = st.executeQuery("SELECT* FROM accounts WHERE (username='"+userNameE+"') AND AES_DECRYPT(password,'enigma');");
- while(rt.next()){
- passwordF = rt.getString("password");
- userNameCheck = rt.getString("username");
- // passwordCheck = rt.getString("password");
- accessLevel = rt.getInt(2);
- if (userNameCheck.equals(userNameE) && passwordF.equals(passwordE)) {
- con.close();
- if(accessLevel == 1){
- mu.setVisible(true);
- mu.jButton1.setEnabled(false);
- mu.jButton2.setEnabled(false);
- loginFail = false;
- con.close();}
- if(accessLevel == 2){
- mu.setVisible(true);
- mu.jButton5.setEnabled(false);
- loginFail = false;
- con.close();
- }
- System.out.println("Disconnected from database");
- this.dispose();
- }
- }
- } catch (SQLException e) {System.err.println("ERROR: " + e.getMessage()); }
- if (loginFail == true){
- new aquarium.confirmations.LoginError().setVisible(true);
- this.dispose();
- }
Add Comment
Please, Sign In to add comment