Error Connecting to Access Database

5 ビュー (過去 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 Center および File ExchangeDatabase Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by