views:

34

answers:

2

Does anyone know how to access a Microsoft 2010 Access database from a Java program running on a Windows Vista OS? An open source, or at least free solution would be preferred, but I will consider a commercial product if necessary.

I have tried a number of ways that I turned up by searching the web (all based on ODBC->JDBC), but none of them seem to work.


Murdoch, thanks for your answer. My response was too big for a comment, so I'll add it here.

Unfortunately, I don't seem to be able to set up the ODBC bridge on Vista running Microsoft Access 2010. The "System DSN" tab of the ODBC Data Source Administrator only displays the SQL-Server driver when I click on the "Add..." button.

I'd like to set up a System DSN, but, if I have to, I might be able to do with a User DSN. When I open the "User DSN" tab I see "MS Access Database" listed, but if I select it and click the "Configure..." button a message box pops up telling me that "The setup routines for the Microsoft Access Driver (*.mdb, *.accdb) ODBC driver could not be found. Please reinstall the driver." I have tried a number of workarounds that I have found on the web, but none of them seem to work for me.

A: 

You need to use the JDBC ODBC Bridge driver, create an ODBC datasource and connect using JDBC something like this.

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:<data-source-name>");

EDIT: I should have also added, you can set up the ODBC data source in the control panel, goto Control Panel > Administrative Tools > Data Sourced (ODBC)

murdoch
A: 

I think I found the solution. If you are having a similar problem take a look at http://msmvps.com/blogs/spywaresucks/archive/2007/05/11/897398.aspx.

Ken