Has anyone connected Matlab to a MS Azure SQL database?

11 ビュー (過去 30 日間)
Andre
Andre 2016 年 6 月 6 日
回答済み: Jose Ibanez 2020 年 3 月 26 日
Has anyone connected Matlab to a MS Azure SQL database? I normally connect to a local DB via ODBC connection; how would you do this for Azure SQL?

採用された回答

Antti
Antti 2016 年 11 月 29 日
編集済み: Antti 2018 年 11 月 22 日
Hi Andre,
I was able to connect to an Azure SQL database by doing the following:
  • 1. Download and install the JDBC drivers that support Azure (> 4.0 I think)
  • 2. In MATLAB, open classpath.txt, and add the path to your JDBC driver (e.g. C:\Program Files\sqljdbc_6.0\enu\sqljdbc4.jar) on the last line of the classpath.txt file. Restart MATLAB.
  • 3. Open the Database Explorer tool in MATLAB (requires Database toolbox):
>> dexplore % R2017a or earlier
>> databaseExplorer % R2017b or later
  • 4. R2017a or earlier: close the dialog that pops up. Click "New", select JDBC source. R2017b or later: click "Configure Data Source"
  • 5. In the dialog, give your data connection a local name, then fill in the details of your SQL server
  • 6. Click 'test' to test the connection, and save
  • 7. In the app, click "New Query" (R2017b or later) or "Connect" (R2017a or earlier)
If you get an error message about data connection, configure your Azure SQL server to accept connections from your computer
Hope this works for you!

その他の回答 (2 件)

Jose Ibanez
Jose Ibanez 2020 年 3 月 26 日
id = 'MySqlUser' ;
pwd = 'MySQLPassword';
sDriver ='com.microsoft.sqlserver.jdbc.SQLServerDriver';
sqlSDriverPath = 'C:\Apps\sqlserverjdbdc\sqljdbc_4.2\enu\jre8\sqljdbc42.jar';
javaaddpath({sqlSDriverPath});
sqlDBInfo = 'jdbc:sqlserver://myAzureDatabaseFolder.somecharacters.database.windows.net; database=MyDB';
MyConnection = database('', id, pwd, sDriver, sqlDBInfo);

Andre
Andre 2019 年 2 月 21 日
Thank you very much, I will definitely try this.

カテゴリ

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