How to use Database Toolbox to query ACCDB/MDB file programmatically without JDBC/ODBC bridge on Windows

20 views (last 30 days)
Starting R2017b, MATLAB Database Toolbox no longer supports JDBC/ODBC bridge because MATLAB starts using JRE version 8. How can I query ACCDB/MDB file on Windows with Database Toolbox?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 18 Jun 2019
Edited: MathWorks Support Team on 18 Jun 2019
Please consider adding/removing the ODBC data source using command line options in Windows. Please refer to the following page from Microsoft for commands such as 'odbcconf' in command prompt or 'Add-OdbcDsn' in PowerShell:
Since 'odbcconf' is not recommended by Microsoft, please find the following example of using '<https://www.mathworks.com/help/matlab/ref/system.html system>' command in MATLAB to execute PowerShell command 'Add-OdbcDsn' with the following:
>> dbqfilepath = strcat("'dbq=", filepath, "'");
>> dbsource = strcat("powershell;Add-OdbcDsn -Name 'dbdemo' -DriverName 'Microsoft Access Driver (*.mdb, *.accdb)' -DsnType 'User' -Platform '64-bit' -SetPropertyValue ", dbqfilepath);
>> system(dbsource);
The above would help adding the datasource to ODBC and you may then use '<https://www.mathworks.com/help/database/ug/database.html database>' command for native ODBC connection.
To remove the data source, please refer to the following page from Microsoft for the 'Remove-OdbcDsn' PowerShell command:
An example command would look like the following:
system("powershell;Remove-OdbcDsn -Name 'dbdemo' -DsnType 'User' -Platform '64-bit'");

More Answers (0)

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!