Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
- try {
- int len,i = 0;
- String usern,password,us,pass="",passc="";
- char type=' ', temp=' ';
- Class.forName("oracle.jdbc.driver.OracleDriver");
- Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","cam","project");
- Statement stat = con.createStatement();
- usern=t1.getText();
- password=new String(p1.getPassword());
- ResultSet rs= stat.executeQuery("select password,type,name from login where loginid='"+usern+"'");
- if(rs.next())
- {
- us = rs.getString(3);
- pass = rs.getString(1);
- type = rs.getString(2).charAt(0);
- System.out.println("here"+us);
- }
- len = pass.length();
- while(i!=len)
- {
- temp = pass.charAt(i);
- temp=(char) ((int) temp-2);
- passc += temp;
- i++;
- }
- if(passc.equals(password))
- {
- if(type == 's')
- {
- Student ob=new Student();
- ob.setVisible(true);
- this.setVisible(false);
- } else if(type=='a')
- {
- Admin ob=new Admin();
- ob.setVisible(true);
- this.setVisible(false);
- } else {
- Teacher ob=new Teacher();
- ob.setVisible(true);
- this.setVisible(false);
- }
- }
- else
- {
- //JOptionPane.showMessageDialog(this,"Invalid userId or password");
- l3.setText("Invalid userId or password");
- t1.setText("");
- p1.setText("");
- }
- } catch (ClassNotFoundException | SQLException ex) {
- Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
Add Comment
Please, Sign In to add comment