Using Matlab and its database toolbox, I need to connect to an Azure server using Microsoft SQL, using the Azure ActiveDirectoryPassword authentication mode. However Azure active directory connections are not natively supported, and some extra steps are required. Matlab uses Java, so it is via Java drivers and libraries that I need to set up the connection to my database. In the latest iteration of me trying to solve this issue, I encounter the following connection error: JDBC Driver Error: Failed to load ADAL4J Java library for performing ActiveDirectoryPassword authentication.
Via this somewhat related question: https://forum.knime.com/t/connect-to-azure-database/20585, I was referred to the Microsoft page on how to setup the connection: https://docs.microsoft.com/en-us/sql/connect/jdbc/connecting-using-azure-active-directory-authentication?view=sql-server-ver15. The instructions on this page tell me On the client machine (on which, you want to run the example), download the azure-activedirectory-library-for-java library and its dependencies, and include them in the Java build path.
Following up, the Microsoft webpage forwards me to the Github page, to install the ADAL libraries.
Now, here the confusion continues, because I have zero clue what to do next. I don't know any Java, and I am not even using Java directly as everything runs via Matlab functionality that uses Java in the background (The only thing I do is use a connection URL to setup the connection to the database). The help files on the ADAL/MSAL Github are unclear for a novice like me and do not seem to be focused towards helping simple Windows users setup all the libraries. So I am looking for help to get everything running.
What is currently running?
- Operating system: Windows 10 64-bit on server infrastructure
- Java: on the pc in question AdoptOpenJDK Java is installed, version
jdk-8.0.265.01-hotspot - Matlab: I have two setups that I need to get working, Matlab 2017a and Matlab 2020a. Matlab 2017a only supports up to Java 7 and Matlab 2020a works with Java 8. It also seems that (some parts of) Java are shipped with Matlab. Using the
version -javacommand in Matlab, I obtain the following information:- Matlab 2017a:
Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode - Matlab 2020a:
Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
- Matlab 2017a:
- JDBC-driver: via Microsoft JDBC I downloaded two versions of JDBC drivers:
Microsoft JDBC DRIVER 6.4 for SQL ServerandMicrosoft JDBC DRIVER 8.4 for SQL Server. Matlab 2017a will use driver 6.4 (because it uses Java 7) and Matlab 2020a will use driver 8.4.
My questions:
- Do I use ADAL or MSAL?
- How do I get the library I need included in Java such that Matlab can use it?
What I tried:
- I downloaded the .jar file for MSAL and included it in the
javaclasspathof Matlab, hoping that that would include the MSAL-library in Matlab-Java. Unfortunately that doesn't work. - I looked at the ADAL github, trying to figure out how to get that integrated into Java. However I do not understand how to make that happen.
Any help would be greatly appreciated, thank you!