How to connect Java 8 to MS Access?

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"); } } } 
+5
source share
2 answers

The JDBC-ODBC bridge is deprecated and has been removed from Java 8, so .getConnection("jdbc:odbc:... just doesn't work. For an alternative, see

Manipulating an Access Database from Java without ODBC

+4
source

By running Java 1.8 , you must use the ucanaccess ie driver; " net.ucanaccess.jdbc.UcanaccessDriver " to connect to the MS Access database through the JDBC program

Read the full example with driver information http://www.benchresources.net/jdbc-msaccess-database-connection-steps-in-java-8/

0
source

Source: https://habr.com/ru/post/1232607/


All Articles