Thursday, October 25, 2012

Code used in video "Java prog#3. Login Program for Netbeans java with sqlite [ Mysql ] database PART-1" and "Java prog#3. Login Program for Netbeans java with sqlite [ Mysql ] database PART-2"

Here I am providing the downloadable code link of  the java code I have used in the video
 " "Java prog#3. Login Program for Netbeans java with sqlite [ Mysql ] database PART-1" and  "Java prog#3. Login Program for Netbeans java with sqlite [ Mysql ] database PART-2""  of my YouTube channel ProgrammingKnowledge


Click Link to watch the video LINK


This code below is for the Login button action perform


    private void cmd_loginActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
        String sql ="select * from Empoyeeinfo where username=? and password=?";
        try{
        pst=conn.prepareStatement(sql);
        pst.setString(1,txt_username.getText());
        pst.setString(2,txt_password.getText());
        //////////////////////////////////////////////
        ///////////
        rs=pst.executeQuery();
        if(rs.next()){
        JOptionPane.showMessageDialog(null, "Username and Password is correct ");
  rs.close();
      pst.close();
       close();
        Employee_info s =new Employee_info();
       s.setVisible(true);
     
        }
        else{
         JOptionPane.showMessageDialog(null, "Username and Password is not correct");
     
     
        }
        }
        catch(Exception e)
    {
           JOptionPane.showMessageDialog(null, e);

    } finally {
try{
  rs.close();
      pst.close();
 
  }
  catch(Exception e) {
                   }
      }
    }


If you have question in mind that  How can we give roles between the manager and the rest of the users...............then follow the code below.... This code below is for the Login button action perform for  the manager and the rest of the users.....



 private void cmd_loginActionPerformed(java.awt.event.ActionEvent evt) {
try{

int count=0;

String sql="select * from employee_data where username =? and userpassword =? and Division =? ";

pst =conn.prepareStatement(sql);



pst.setString(1, txt_username.getText());
pst.setString(2, txt_password.getText());



pst.setString(3, txt_userlevel.getSelectedItem().toString());

rs=pst.executeQuery();



//query for welcome name
{
}
while(rs.next()){



count=count+1;

}

String division= (txt_userlevel.getSelectedItem().toString());

if(division=="Top") {


if(count==1){

JOptionPane.showMessageDialog(null, "Username and password correct");

User_JFrame p= new User_JFrame();

//Admin_HR_JFrame p = new Admin_HR_JFrame();

p.setVisible(true);

close();

}

else if(count>1){

JOptionPane.showMessageDialog(null, "Duplicate user and password Access denied");
// Level_1_JForm s = new Level_1_JForm();

//s.setVisible(true);

}

else{

JOptionPane.showMessageDialog(null, "Username and password not correct");

}

} 

else if(division=="Manager"){

if(count==1){

JOptionPane.showMessageDialog(null, "Username and password correct");


Competency_Form_JFrame s = new Competency_Form_JFrame();

s.setVisible(true);

close();

}

else if(count>1){

JOptionPane.showMessageDialog(null, "Duplicate user and password Access denied");
// Level_1_JForm s = new Level_1_JForm();



//s.setVisible(true);



}



else{



JOptionPane.showMessageDialog(null, "Username and password not correct");

}

} 

else if(division=="Executive"){

if(count==1){

JOptionPane.showMessageDialog(null, "Username and password correct");

Competency_Form_JFrame s = new Competency_Form_JFrame();



s.setVisible(true);

close();

}

else if(count>1){

JOptionPane.showMessageDialog(null, "Duplicate user and password Access denied");

//Level_1_JForm s = new Level_1_JForm();



//s.setVisible(true);

}

else{

JOptionPane.showMessageDialog(null, "Username and password not correct");

}

} 
else if(division=="Engineer"){



if(count==1){

JOptionPane.showMessageDialog(null, "Username and password correct");

Competency_Form_JFrame s = new Competency_Form_JFrame();

s.setVisible(true);

close();

}

else if(count>1){

JOptionPane.showMessageDialog(null, "Duplicate user and password Access denied");
// Level_1_JForm s = new Level_1_JForm();

//s.setVisible(true);

}

else{

JOptionPane.showMessageDialog(null, "Username and password not correct");

}

} 


else if(division=="DesignEngineer"){

if(count==1){



JOptionPane.showMessageDialog(null, "Username and password correct");


Competency_Form_JFrame s = new Competency_Form_JFrame();

s.setVisible(true);

close();

}

else if(count>1){

JOptionPane.showMessageDialog(null, "Duplicate user and password Access denied");

//Level_1_JForm s = new Level_1_JForm();

//s.setVisible(true);

}

else{

JOptionPane.showMessageDialog(null, "Username and password not correct");

}

} 


}catch(Exception e)

{

JOptionPane.showMessageDialog(null, e);

}
}

Java prog#3. Login Program for java with sqlite [ Mysql ] database PART-1



JPasswordfield
The sql connect jar file can be downloader form this link below




Creating Login Page In Java using NetBeans
code for login using netbeans
Java Netbeans Login
Building a Login Screen for a NetBeans
NetBeans Platform Login Tutorial
create login page contain user id,password,buttons in java using netbeans
NetBeans Platform Login Tutorial
Download Netbeans Login Source Codes


Java prog#3. Login Program for java with sqlite [ Mysql ] database PART-2 



The sql connect jar file can be downloader form this link below

http://code.google.com/p/sqlitebot/downloads/detail?name=sqlitejdbc-v056.jar&can=2&q=

IT Certification Category (English)640x480

Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com


Top Online Courses From ProgrammingKnowledge

Python Course http://bit.ly/2vsuMaS
Java Coursehttp://bit.ly/2GEfQMf
Bash Coursehttp://bit.ly/2DBVF0C
Linux Coursehttp://bit.ly/2IXuil0
C Course http://bit.ly/2GQCiD1
C++ Coursehttp://bit.ly/2V4oEVJ
PHP Coursehttp://bit.ly/2XP71WH
Android Coursehttp://bit.ly/2UHih5H
C# Coursehttp://bit.ly/2Vr7HEl
JavaFx Coursehttp://bit.ly/2XMvZWA
NodeJs Coursehttp://bit.ly/2GPg7gA
Jenkins Course http://bit.ly/2Wd4l4W
Scala Coursehttp://bit.ly/2PysyA4
Bootstrap Coursehttp://bit.ly/2DFQ2yC
MongoDB Coursehttp://bit.ly/2LaCJfP
QT C++ GUI Coursehttp://bit.ly/2vwqHSZ