Guest User

Untitled

a guest
Nov 23rd, 2016
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
  2. try {
  3. int len,i = 0;
  4. String usern,password,us,pass="",passc="";
  5. char type=' ', temp=' ';
  6. Class.forName("oracle.jdbc.driver.OracleDriver");
  7. Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","cam","project");
  8. Statement stat = con.createStatement();
  9. usern=t1.getText();
  10. password=new String(p1.getPassword());
  11. ResultSet rs= stat.executeQuery("select password,type,name from login where loginid='"+usern+"'");
  12. if(rs.next())
  13. {
  14. us = rs.getString(3);
  15. pass = rs.getString(1);
  16. type = rs.getString(2).charAt(0);
  17. System.out.println("here"+us);
  18. }
  19. len = pass.length();
  20. while(i!=len)
  21. {
  22. temp = pass.charAt(i);
  23. temp=(char) ((int) temp-2);
  24. passc += temp;
  25. i++;
  26. }
  27. if(passc.equals(password))
  28. {
  29. if(type == 's')
  30. {
  31. Student ob=new Student();
  32. ob.setVisible(true);
  33. this.setVisible(false);
  34. } else if(type=='a')
  35. {
  36. Admin ob=new Admin();
  37. ob.setVisible(true);
  38. this.setVisible(false);
  39. } else {
  40. Teacher ob=new Teacher();
  41. ob.setVisible(true);
  42. this.setVisible(false);
  43. }
  44. }
  45. else
  46. {
  47. //JOptionPane.showMessageDialog(this,"Invalid userId or password");
  48. l3.setText("Invalid userId or password");
  49. t1.setText("");
  50. p1.setText("");
  51. }
  52. } catch (ClassNotFoundException | SQLException ex) {
  53. Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
  54. }
  55.  
  56.  
  57. }
Add Comment
Please, Sign In to add comment