Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String pass;
- user = tf_User.getText();
- pass = new String(pf_Pass.getPassword());
- try
- {
- Class.forName("java.sql.Driver");
- Connection cn = DriverManager.getConnection("jdbc:mysql://localhost:3306/bag_shop","root","root");
- Statement stmt = cn.createStatement();
- String query = "Select utype from users where uname = '"+user+"' and password = '"+pass+"' ";
- ResultSet rs = stmt.executeQuery(query);
- if(rs.next())
- {
- JOptionPane.showMessageDialog(this, "Login Match! \nWelcome Mr. "+user+"\nPress Ok To Proceed!");
- utype = rs.getString("utype");
- MainForm mf = new MainForm();
- mf.show();
- this.hide();
- }
- else
- {
- i--;
- tf_User.setText("");
- pf_Pass.setText("");
- if(i==0)
- {
- dispose();
- JOptionPane.showMessageDialog(this, "Sorry your 3 chances are over.\nPlease restart program!");
- }
- else
- {
- JOptionPane.showMessageDialog(this, "Login Not Match! \nOnly " +i+ " attempt remaining!");
- }
- }
- }
- catch(Exception e)
- {
- JOptionPane.showMessageDialog(this,e);
- }
Add Comment
Please, Sign In to add comment