0% found this document useful (0 votes)
15 views2 pages

User Login Functionality in Java

The document contains Java code for a user login system that connects to a MySQL database. It executes a SQL query to verify the username, password, and user type, displaying a message upon successful login and redirecting users to different interfaces based on their user type. If the login fails, an error message is shown to the user.

Uploaded by

davidlatigo800
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views2 pages

User Login Functionality in Java

The document contains Java code for a user login system that connects to a MySQL database. It executes a SQL query to verify the username, password, and user type, displaying a message upon successful login and redirecting users to different interfaces based on their user type. If the login fails, an error message is shown to the user.

Uploaded by

davidlatigo800
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

try{

String query;

query = "SELECT * FROM `user login` WHERE Username=? and


Password =? and Usertype=?";

con = [Link]("jdbc:mysql://localhost/gaga medical


center", "root", "");

pst = [Link](query);

[Link](1, [Link]());

[Link](2, [Link]());

[Link](3, [Link]([Link]()));

rs=[Link]();

if([Link]()){

[Link](this, "username and password Matched and


you are logined as "+[Link]("usertype"));

if([Link]() ==0){

Admin a = new Admin();

[Link](true);

[Link](false);

}else if([Link] ()==1){

Admin a = new Admin();

a . setVisible(true);

[Link](false);

}else if([Link] ()==2){

Doctor D = new Doctor();

D . setVisible(true);

[Link](false);

}else if([Link] ()==3){


Admin a = new Admin();

a . setVisible(true);

[Link](false);

[Link](false);

}else if([Link]()==4 ){

Admin a = new Admin();

a . setVisible(true);

[Link](false);

[Link](false);

}else{

[Link](this, "username and password do not


matched");

}catch (Exception ex){

[Link](this, [Link]());

You might also like