To download the JDBC driver (mssql-jdbc-x.x.x.jrex.jar) and the authentication DLL (mssql-jdbc_auth-x.x.x.x64.dll referenced in this solution, select the "Microsoft SQL Server JDBC" option at this link:
1. On the development machine, add the JDBC Driver and the authentication DLL as "required files" when compiling the Web App CTF archive.
2. On the server machine, install the JDBC driver JAR file and add it to the MATLAB Runtime Java class path. Edit the file "classpath.txt" inside your MATLAB Runtime installation's "toolbox\local" directory and add the absolute location of the JAR file to the end of the list. Note that the path you enter must include the name of the JAR file as well. You must restart the server instance for this change to take effect.
If you have not done this, you will encounter a "JDBC Driver not found" error.
3. Install the authentication DLL on the server machine and add it to the MATLAB Runtime Java library path.
Edit the file "librarypath.txt" inside your MATLAB Runtime installation's "toolbox\local" directory and add the absolute location of the folder containing the DLL to the list
(only the path to the folder containing the DLL, not the path to the DLL itself)
. You must restart the server instance for this change to take effect.
If you have not done this, you will encounter a "JDBC Driver not configured for integrated authentication" error.
4. Configure your Web App Launcher service to start under a Windows user that has been given access to the database.
Because you are trying to use Windows Authentication to establish a connection to the database, the login information for the requested connection is obtained from the Windows user profile that is attempting to connect. That means, when running the app on your Web App Server, the Windows user that is running the Web App is the one that will give its login information to attempt a database connection. You will need to configure the MATLAB Web App Launcher service to run under a Windows user that has access to the database. You can do this using one of the following methods:
a. Give the default Web App Launcher service user (MwWebAppWorkerR2021b) access to your SQL database
b. Configure the user that the Web App Launcher service runs under. For information on how to do this when creating a new server, see this documentation link:
Otherwise, if you want to configure an existing Web App server, see this MATLAB Answers post:
If you have not done this, you will receive a "JDBC Driver Error: Login failed." error.