Wednesday, August 31, 2011

Connect to SQL Azure from Matlab

1. Download the SQL Server JDBC Driver 3.0, a Type 4 JDBC driver that provides database connectivity through the standard JDBC application program interfaces (APIs) available in Java Platform, Enterprise Edition 5 and above. This version of SQL Server JDBC Driver 4.0 adds support for SQL Azure.
2. Execute it, and it will be decompressed to the selected location

3. Create folder c:/SQLJDBC and place sqljdbc_3.0 inside it.

4. Start the Notepad application as administrator and open the file:

C:\Program Files\MATLAB\R2011b\toolbox\local\classpath.txt

5. Add a reference like this to the JDBC driver after the last line of that file:

c:/SQLJDBC/sqljdbc_3.0/enu/sqljdbc4.jar

6. After that you have to restart MATLAB and then you can test the connection:

dbConn = database('master', 'user', 'password', 'com.microsoft.sqlserver.jdbc.SQLServerDriver', 'jdbc:sqlserver://sqlazurepath;databaseName=master;');

7. To test the connection you can execute:

ping(dbConn);

1 comment:

  1. updated jdbc driver: https://www.microsoft.com/en-US/download/details.aspx?id=11774

    ReplyDelete