How to configure UCanAccess JDBC driver with Spring?

Tags: , , , ,

Whenever I tried to use an ODBC driver to access MDB files, it gave me an error:

error : "[Microsoft][ODBC Driver Manager] Invalid string or buffer length exception"

So I decided to use the UCanAccess JDBC driver instead.

Does anyone have experience configuring UCanAccess JDBC driver with Spring?

I’ve put the UCanAccess.jar into my lib folder and configured it like below, but that doesn’t work:

<bean id="dataSource" 
    <property name="driverClassName" ref="jdbcDriver" />
    <property name="url" value="jdbc:ucanaccess://C:\XXXX.mdb" />
    <property name="username" value="" />
    <property name="password" value="" />

<bean id="jdbcDriver" class="net.ucanaccess.jdbc.UcanaccessDriver" />

My development environment: Spring Framework 3.x with JdbcTemplate, Windows 7 64bit, Microsoft Access 2013.


You have to put all UCanAccess dependencies in your lib folder (see the jars in the lib folder of the UCanAccess distribution: jackcess, hsqldb,commons-logging and commons-lang).

Source: stackoverflow