I have a mdb-file which I want to read through Java. For that I imported the dependencies through maven.I have the ojdbc8 lib (version 18.3.0.0), the ucanaccess lib (version 5.0.0) and after I read that the jackcess version should be up to date I manually set the jackcess lib to 3.5.0.
<groupId>groupId</groupId>
<artifactId>Access-DB</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.oracle.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>18.3.0.0</version>
</dependency>
<dependency>
<groupId>net.sf.ucanaccess</groupId>
<artifactId>ucanaccess</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>com.healthmarketscience.jackcess</groupId>
<artifactId>jackcess</artifactId>
<version>3.5.0</version>
</dependency>
</dependencies>
But I still get the Unsupported newer Version-Error:
net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::5.0.0 Unsupported newer version: 51
at net.ucanaccess.jdbc.UcanaccessDriver.connect(UcanaccessDriver.java:231)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:270)
at main.java.AccessDB.main(AccessDB.java:14)
Caused by: java.io.IOException: Unsupported newer version: 51
at com.healthmarketscience.jackcess.impl.JetFormat.getFormat(JetFormat.java:310)
at com.healthmarketscience.jackcess.impl.DatabaseImpl.<init>(DatabaseImpl.java:538)
at com.healthmarketscience.jackcess.impl.DatabaseImpl.open(DatabaseImpl.java:415)
at com.healthmarketscience.jackcess.DatabaseBuilder.open(DatabaseBuilder.java:267)
at net.ucanaccess.jdbc.DefaultJackcessOpener.open(DefaultJackcessOpener.java:37)
at net.ucanaccess.jdbc.DBReference.<init>(DBReference.java:170)
at net.ucanaccess.jdbc.DBReferenceSingleton.loadReference(DBReferenceSingleton.java:51)
at net.ucanaccess.jdbc.UcanaccessDriver.connect(UcanaccessDriver.java:91)
... 3 more
The script I use to read the Access file looks like this:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class AccessDBConnection {
public static void main(String ar[]) {
try {
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
Connection conn=DriverManager.getConnection("jdbc:ucanaccess://access/remote.mdb");
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("select * from summary_0199_550");
System.err.println("asdasda");
while (rs.next()) {
System.out.println(rs.getString(1));
}
} catch ( Exception ee) {
ee.printStackTrace();
//System.out.println(ee);
}
}
}
The libraries are all there:
