0% found this document useful (0 votes)
16 views

Program 6

Uploaded by

omchudasama3688
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Program 6

Uploaded by

omchudasama3688
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

import java.sql.

*;
import java.io.*;
import java.util.*;
public class prog6
{
public static void main(String args[])throws Exception
{
Class.forName("com.mysql.jdbc.Driver");
Connection
conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/abc","root","");
System.out.println("Connection successfull");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter User Name :");
String un=br.readLine();
System.out.println("Enter Password :");
String pw=br.readLine();

Statement st=conn.createStatement();
ResultSet rs=st.executeQuery("select * from user");
String tab_un,tab_pw;
int count=0;
while(rs.next())
{
tab_un=rs.getString(1);
tab_pw=rs.getString(2);

if(un.equals(tab_un) && pw.equals(tab_pw))


{
count=count+1;
break;
}
else
{
count=0;
}
}
if(count>0)
{
System.out.println("Correct username and password entered!!!");
}
else
{
System.out.println("Wrong username or password entered......");
}
}
}

You might also like