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"

10:58 AM

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=

Written by

We are one of the initiators of the development of information technology in understanding the need for a solution that is familiar and close to us.

0 comments:

Post a Comment

 

© 2013 Klick Dev. All rights resevered.

Back To Top