I am trying to use UCanAccess to read data from a MS Access database in Mac OSX.8. I believe that I have set everything up according to the UCanAccess directions and those provided by Gord Tompson in a StackOverflow answer. This is the error that I am getting:
Exception in thread "main" java.lang.IncompatibleClassChangeError: Found class com.healthmarketscience.jackcess.Database, but interface was expected
at net.ucanaccess.jdbc.DBReference.(DBReference.java:149) at net.ucanaccess.jdbc.DBReferenceSingleton.loadReference(DBReferenceSingleton.java:57) at net.ucanaccess.jdbc.UcanaccessDriver.connect(UcanaccessDriver.java:100) at java.sql.DriverManager.getConnection(DriverManager.java:582) at java.sql.DriverManager.getConnection(DriverManager.java:207) at openACCDB.OpenACCDB.main(OpenACCDB.java:13)
My build path includes the following:
commons-lang-2.6.jar commons-logging-1.1.1.jar hsqldb.jar jackcess-2.0.4.jar ucanaccess-2.0.8.jarDoes anyone have any advice? My understanding is that UCanAccess and Jackcess are platform independent, but do I need something in addition akin to the MS Jet Engine to run in Mac OSX?
This is my code:
package openACCDB
import java.sql.*;
import java.io.File;
public class OpenACCDB {
public static void main(String args[]) throws ClassNotFoundException,
SQLException {
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
String database = "/Users/george/Eclipse_Files/Java/GEOA_250/MyAccess.accdb";
if ((new File(database)).exists()) {
Connection conn = DriverManager.getConnection("jdbc:ucanaccess://"+database);
Statement stmt = conn.createStatement();
ResultSet rslt = stmt.executeQuery("SELECT [name] FROM [table1]");
while (rslt.next())
System.out.println(rslt.getString(1));
}
else System.out.println("The file "+database+"\n\tdoes not exist");
}
}