How do I deploy a MATLAB function which uses Database Toolbox functionality with Microsoft SQL Server Integrated Security?

9 views (last 30 days)
I am using a Database connection to a Microsoft SQL Server with Integrated Security in my MATLAB function. I had to update librarypath.txt and classpath.txt and then this works fine inside MATLAB. Now I want to use MATLAB Compiler to create a standalone application. How do I include sqljdbc4.jar and sqljdbc_auth.dll in my application such that it can also use the database connection with integrated security?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 24 Feb 2016
The most portable way to deploy such an application would be the following:
For MATLAB/Database Toolbox releases R2012b and newer:
1. When following the instructions to add the directory containing the authentication DLLs to the MATLAB Java Library Path, do not work with $MATLABROOT\toolbox\local\librarypath.txt but use $PREFDIR\javalibrarypath.txt instead. (Where $PREFDIR stands for the directory returned by the prefdir function. Further javalibrarypath.txt does not exist by default so you may need to create it by yourself). When writing the file, do not only add the directory containing the DLL on your development machine; also add a line containing a single dot. The MCR will interpret this dot as "the current directory", this will allow us to place sqljdbc_auth.dll next to your EXE-file of the deployed application. (Note that $PREFDIR\javalibrarypath.txt automatically gets compiled into the application at compile time).
2. Compile sqljdbc4.jar into your application by adding it to the "Shared Resources and Helper Files" (or "Files required for your application to run" in later MATLAB versions) in DEPLOYTOOL or by using the -a option with MCC.
3. Whenever you distribute your application to someone else, make sure that sqljdbc_auth.dll is indeed placed next to the EXE-file.
For MATLAB/Database Toolbox releases R2012a and earlier:
1. Compile sqljdbc4.jar into your application by adding it to the "Shared Resources and Helper Files" in DEPLOYTOOL or by using the -a option with MCC.
2. Create a copy of your librarypath.txt and in this copy replace the directory name of the directory containing sqljdbc_auth.dll with a single dot "." (without the quotes). MATLAB will interpret this dot as "the current directory".
3. Place this new librarypath.txt in the same directory as your standalone EXE-file (i.e. which at runtime will be "the current directory" as above). Also place sqljdbc_auth.dll in this directory.
4. Whenever you distribute your application to someone else, make sure that librarypath.txt and sqljdbc_auth.dll are indeed placed next to the EXE-file.
  4 Comments
Marc Youcef
Marc Youcef on 23 Aug 2019
In case of Web App, you have to add the DLL directory to the librarypath.txt in Local/toolbox from your Runtime Installation folder. Same for you jar file full file path in classpath.txt from runtime installation folder.

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Products


Release

R2012a

Community Treasure Hunt

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

Start Hunting!