2

I am facing some issue to making a login page in java using ms access database. its not getting username and password from ms access database.

try
{
String user=t.getText().trim();
String pass=t1.getText().trim();
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con1=DriverManager.getConnection("jdbc:odbc:balogin");
Statement stat;
stat=con1.createStatement();
ResultSet rs=stat.executeQuery("select * from Table1 where user='"+user+"' and pass='"+pass+"'");
System.out.println("select * from Table1 where user='"+user+"' and pass='"+pass+"'");
int count=0;
while(rs.next())
{
{count=count+1;}
if(count==1)
{
JOptionPane.showMessageDialog(null,"User Found,Access Granted");
ControlPanel cp1=new ControlPanel();
cp1.display();
}
else
{
JOptionPane.showMessageDialog(null,"User not found");
}
}
}
Gord Thompson
  • 116,920
  • 32
  • 215
  • 418
AmanKumar
  • 1,333
  • 2
  • 20
  • 33

1 Answers1

5

The JDBC-ODBC Bridge is obsolete and has been removed from Java 8, so .getConnection("jdbc:odbc:... is simply not going to work. For an alternative see

Manipulating an Access database from Java without ODBC

Community
  • 1
  • 1
Gord Thompson
  • 116,920
  • 32
  • 215
  • 418