package jdbc;
import java.sql.*;
import java.util.Scanner;
public class JDBC {
public static void main(String[] args) {
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/mca","root","");
Statement stmt=con.createStatement();
Scanner sc =new Scanner(System.in);
System.out.print("Enter Name For Login : ");
String uname = sc.nextLine();
System.out.print("Enter Name For Password : ");
String upassword = sc.nextLine();
ResultSet rs=stmt.executeQuery("select * from login where uname='"+uname+"'");
if(rs.next())
{
if(uname.equalsIgnoreCase(rs.getString(2)) && upassword.equals(rs.getString(3)))
{
System.out.println("Login Success Welcome "+uname+",");
}
else
{
System.out.println("Username And Password Inrorrect Forgot Password");
}
}
else
{
System.out.println("Username And Password Inrorrect Forgot Password");
}
con.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
No comments:
Post a Comment