Error Connecting to Access Database

조회 수: 8 (최근 30일)
Jim
Jim 2014년 8월 28일
답변: Bereketab Gulai 2020년 5월 20일
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
Geoff Hayes
Geoff Hayes 2014년 8월 28일
Jim - have you added the JDBC driver to the java static path? See MS SQL Server JDBC Windows for an example.

댓글을 달려면 로그인하십시오.

답변 (2개)

Jim
Jim 2014년 9월 8일
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
Jim
Jim 2014년 9월 8일
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.

댓글을 달려면 로그인하십시오.


Bereketab Gulai
Bereketab Gulai 2020년 5월 20일

카테고리

Help CenterFile Exchange에서 Database Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by