I had a problem creating a login page in java using ms access database. it does not get 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"); } } }
source share