## Connect to a MS Access database (*.accdb)

1

The JDBC Connections section of the help file http://reference.wolfram.com/mathematica/DatabaseLink/tutorial/DatabaseConnections.html gives me the impression that I can connect to a MS Access Database (*.accdb) using the following statements:

<< DatabaseLink;
conn = OpenSQLConnection[JDBC["odbc", "MTData.accdb"]];


where MTData.accdb is the name of my database. I have verified that the file does exist using FileNames[]. Upon executing the statements above, however, I receive the following error message:

JDBC::error: "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified ...".

Typing JDBCDriverNames[] gives a list with "Microsoft Access(ODBC)"

Would somebody please be able to clarify whether I should be able to access a MS Access database using these statements? Thanks.

EDIT:

I have also tried accessing the database by providing a DSN (Data Source Name), created by opening the ODBC Source Administrator (as I have a 64-bit operating system, but 32-bit Office, I used the program at location C:\Windows\SysWOW64\odbcad32.exe). Executing the following code, where "MTDB" is the DSN: conn = OpenSQLConnection[JDBC["odbc", "MTDB"]];, I get the following error message:

JDBC::error: [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application

Question was closed 2013-07-30T15:28:54.957

If it's just a matter of forcing the use of a 32-bit JVM, you can launch one as follows. You probably already have a 32-bit Java installed at the following location, and if not, you can install one from java.com. Needs["JLink"]; ReinstallJava[CommandLine->"C:\\Program Files (x86)\\Java\\jre7\\bin\\javaw"]. – Todd Gayley – 2013-07-30T14:39:19.817

@ToddGayley Thank-you! This works - I am able to access the database using the data source name (created using C:/Windows/SysWOW64/odbcad32.exe) and using conn = OpenSQLConnection[JDBC["odbc", "mydatasourcename"]]; Note however that I could not connect using a named connection. Given that this question is marked a duplicate, perhaps it is worthwhile putting your answer in the other question. – MLD – 2013-07-31T01:17:47.353

I have added the above remark into that older question. – Todd Gayley – 2013-07-31T15:54:52.470