Question

I have to define a new Driver in the Netbeans "Services" Tab
Services->Databases->Drivers->new Driver...
because I want use the "Entity Classes from Database"-Wizard in context with UCanAccess.
1st step: "new Driver" does work (only declaration ;-) )

  • Driver File(s): f:\WorkspaceNetbeans\MSAccessDB\lib\UCanAccess-2.0.4-bin\ucanaccess-2.0.4.jar
  • Driver Class: net.ucanaccess.jdbc.UcanaccessDriver
  • Name:msaccess

2nd step: "Connect using..."

  • JDBC URL: jdbc:ucanaccess://F:/WorkspaceNetbeans/MSAccessDB/data/Datenbank2.accdb
  • "User Name" and "Password" leave blank

The "Test Connection"-Button results in Error Message:

Cannot establish a connection to jdbc:ucanaccess://F:\WorkspaceNetbeans\MSAccessDB\data\Datenbank2.accdb using
net.ucanaccess.jdbc.UcanaccessDriver (Could not initialize class
net.ucanaccess.jdbc.UcanaccessDriver)

I've got the newest ucanaccess from http://ucanaccess.sourceforge.net/site.html ucanaccess-2.0.4.jar, commons-lang-2.6.jar, commons-logging-1.0.4.jar, hsqldb.jar, jackcess-2.0.3.jar in the Netbeans Classpath.

The old fashion way to connect via jdbc to ucanaccess works fine.

public static void main(String[] args) throws ClassNotFoundException, SQLException {
   String connectString = "jdbc:ucanaccess://" + "f:/WorkspaceNetbeans/MSAccessDB/data/Datenbank2.accdb";
   Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
   Connection conn = DriverManager.getConnection(connectString, "", "");
   conn.createStatement().execute("CREATE TABLE example1 (id COUNTER PRIMARY KEY,descr text(400), number numeric(12,3), date0 datetime) ");
}

The same connection string also works fine make DBeaver able to connect to the MSAccess db.

My set up:
Windows 7 Professional 64 bit
Microsoft Office 2013
NetBeans IDE 8.0
Java 1.8

The problem is similar to: "Conflict between JT400 and UCanAccess?" Conflict between JT400 and UCanAccess?
but the answers there don't help with my problem.

Any ideas to solve my problem?

Was it helpful?

Solution

UCanAccess 2.0.4.1 has been released, now you can configure UCanAccess as NetBeans service. As explained in the UCanAccess web site (tab 'jdbc client tools') you have to:

-in the field Driver File(s), add ucanaccess.jar and all dependencies. I've upgraded the commons-logging in the UCanAccess distribution to the 1.1.1, so you can use that jar with NetBeans8.

-use the following pattern for the jdbc url: jdbc:ucanaccess://;showschema=true Showschema connection property must be setted to true.

OTHER TIPS

I was wrong, it wasn't a tricky task but... To establish the connection you have to list in the Driver File(s) : ucanaccess-2.0.4.jar, commons-lang-2.6.jar, hsqldb.jar, jackcess-2.0.3.jar AND a different version of commons-logging that you can find it in NetBeans: NetBeans 8.0\ide\modules\org-apache-commons-logging.jar (the commons-logging in the UCanAccess distribution is in conflict with that used by NetBeans)

But unfortunatly, after establishing the connection, you won't be able to execute queries through this IDE, because of a trivial bug in the UcanaccessDatabaseMetadata which hasn't effect with the other IDE jdbc clients I tested (Openoffice, Libreoffice, DBeaver, Squirrel, SQLeo and so on) . So, to do this, you have to wait some days (I think I'll post a patched Ucanaccess 2.0.4.1 next week). Also, I'll add a note about UCanAccess configuration as NetBeans service in the UCanAccess web site.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top