Skip to content
Advertisement

How to configure UCanAccess JDBC driver with Spring?

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" 
  class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" ref="jdbcDriver" />
    <property name="url" value="jdbc:ucanaccess://C:\XXXX.mdb" />
    <property name="username" value="" />
    <property name="password" value="" />
</bean>

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

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

Advertisement

Answer

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).

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement