UCanAccess is a pure Java JDBC
driver that allows us to read from and write to Access databases without using ODBC
. It uses two other packages, Jackcess
and HSQLDB
, to perform these tasks.
Once it has been set up*, we can work with data in .accdb and .mdb files using code like this:
import java.sql.*;
Connection conn=DriverManager.getConnection("jdbc:ucanaccess://C:/__tmp/test/zzz.accdb");
Statement s = conn.createStatement();
ResultSet rs = s.executeQuery("SELECT [LastName] FROM [Clients]");
while (rs.next()) {
System.out.println(rs.getString(1));
}
*For more details see the following question:
Manipulating an Access database from Java without ODBC