Error Connecting to Access Database

6 views (last 30 days)
Jim
Jim on 28 Aug 2014
Answered: Bereketab Gulai on 20 May 2020
I am attempting to connect to a MS Access database from Matlab Ver 7.12.0.635 (2011a) but I get an error in con.Message. I performed the following:
dbpath='C:\Users\g553586\Documents\Database1.accdb';
url = [['jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DSN='''';DBQ='] dbpath];
con = database('','','','sun.jdbc.odbc.JdbcOdbcDriver', url);
con
con =
Instance: ''
UserName: ''
Driver: []
URL: []
Constructor: [1x1 com.mathworks.toolbox.database.databaseConnect]
Message: '[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified'
Handle: 0
TimeOut: []
AutoCommit: 'off'
Type: 'Database Object'
  1 Comment
Geoff Hayes
Geoff Hayes on 28 Aug 2014
Jim - have you added the JDBC driver to the java static path? See MS SQL Server JDBC Windows for an example.

Sign in to comment.

Answers (2)

Jim
Jim on 8 Sep 2014
I attempted a different configuration. I defined an ODBC connection to an Access database test.accdb. and called it test_db. In the Matlab command window, I performed the following:
conn = database('test_db','','');
conn.message
ans =
[Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application Please verify that login information and database url are valid.
I researched the error message in Matlab help and found the following: "You tried to open a 32-bit application when running MATLAB® in 64-bit mode." and recommended resolution "Restart MATLAB to run in 32-bit mode using the command matlab –win32." However, when I run that command, Matlab always appears to run in 64-bit mode and I continue to get the same error message. I cannot find any other information on running in 32-bit mode. BR Is there another way to force running in 32-bit mode so that I can connect to the 32-bit Access db? Is there another work around? I am running this on a machine that is fairly locked down so I will have to go through a help desk to make changes to the installation.
  1 Comment
Jim
Jim on 8 Sep 2014
I requested the 32-bit version of Matlab to be installed. I will have to wait a couple days for that to happen. If there is another work around, please post it. Thanks.

Sign in to comment.


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by