Why am I not able to establish a JDBC connection with the "database" function when compiled using MATLAB Compiler R2021b onwards?

3 visualizzazioni (ultimi 30 giorni)
I am trying to connect to a JDBC-based database. I am compiling my code using MATLAB Compiler R2023a and trying to run the compiled code. However, I encounter the following error:
Unable to connect to database or to the URL in the tnsNames file
The issue occurs when the app is compiled using MATLAB Compiler R2021b onwards. The error is thrown when trying to run the compiled app, but there is no error thrown while compiling the app. The app works as expected when run as a script in MATLAB but does not work when run after compiling it.
How can I compile my application using newer versions of MATLAB Compiler and successfully establish a JDBC connection from my deployed application?

Risposta accettata

MathWorks Support Team
MathWorks Support Team il 18 Mar 2024
Prior to MATLAB Compiler R2021b, the contents of MATLAB's preference folder were captured in the standalone application. This became untenable and unnecessarily increased the size of the standalone application with a lot of files that weren't required for its execution. Hence, it was removed from the future releases of MATLAB Compiler. One such file was the “javalibrarypath.txt” file. However, in some cases, it is necessary to include the path to the JDBC driver in a “javalibrarypath.txt” file for the standalone application.
While compiling, you can force its inclusion by adding the “-a” option to your “mcc” command and adding the path to the “javalibrarypath.txt” file. Please refer to the following link for more information:
For example:
mcc -a C:\Users\<user>\AppData\Roaming\MathWorks\MATLAB\<matlab_version>\javalibrarypath.txt
 

Più risposte (0)

Categorie

Scopri di più su MATLAB Compiler in Help Center e File Exchange

Prodotti


Release

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by