1.
Close MATLAB if it is running.
2.
Insert the path to the database driver JAR file in the classpath.txt file. The classpath.txt file is located at:
$MATLABROOT\toolbox\local\classpath.txt
The updated path entry should now include the full path to the driver. For example:
C:\DB_Drivers\sqljdbc_2.0\enu\sqljdbc4.jar
3.
Insert the path to the folder containing sqljdbc_auth.dll in the librarypath.txt file. The librarypath.txt file is located at:
$MATLABROOT\toolbox\local\librarypath.txt
The path entry should not include the file name sqljdbc_auth.dll:
C:\DB_Drivers\sqljdbc_2.0\enu\auth\x64
The sqljdbc_auth.dll file is installed in the following location:
<installation>\sqljdbc_<version>\<language>\auth\<arch>
where <installation> is the installation directory of the SQL server driver.
If you are running a 32-bit Java Virtual Machine (JVM), use the sqljdbc_auth.dll file in the x86 folder, even if the operating system is the x64 version. If you are running a 64-bit JVM on a x64 processor, use the sqljdbc_auth.dll file in the x64 folder. If you are running a 64-bit JVM on a IA-64 processor, use the sqljdbc_auth.dll file in the IA64 folder.
4.
Start MATLAB.
5.
Append the string integratedSecurity=true; to the database URL:
conn = database('dbName','','', ...
'com.microsoft.sqlserver.jdbc.SQLServerDriver', ...
['jdbc:sqlserver://servername:portnumber; '...
'database=dbName;'] 'integratedSecurity=true;')
Best Answer