How do I connect JDBC with compiled application?
古いコメントを表示
Hi,
We are using Matlab to process some data and want to output the result in a database.
To do so, we tried with the Database Toolbox. After some troubleshooting with JDBC Driver path which didn't seem to work out of the box, we have been able to run the script in Matlab this way:
conn = database(databasename, username, password, 'Server', server, 'PortNumber', port, 'Vendor', 'Microsoft SQL Server', 'AuthType', authType);
We are using the Matlab Compiler to produce an exe, the Compiler state that it should support the toolbox here.
When we do so, we still have the following error, which tell us the function does not seem to exists, an error we do not have in Matlab.

What can we do to troubleshoot this issue?
Thanks
For reference here a sample of the full script.
- writetable were added only for debugging
- datainsert is deprecated, sqlwrite should be used, but I could would not let me insert data only and was always generating a create table.
function [] = tampon(server, port, databasename, authType, username, password)
writetable(cell2table({'2'}),'log.txt','WriteVariableNames',false)
conn = database(databasename, username, password, 'Server', server, 'PortNumber', port, 'Vendor', 'Microsoft SQL Server', 'AuthType', authType);
writetable(cell2table({'3'}),'log.txt','WriteVariableNames',false)
load('output.mat');
writetable(cell2table({'4'}),'log.txt','WriteVariableNames',false)
output = output(:,1:5);
writetable(cell2table({'5'}),'log.txt','WriteVariableNames',false)
datainsert(conn,'dbo.test', cellstr(output.Properties.VariableNames), output);
writetable(cell2table({'6'}),'log.txt','WriteVariableNames',false)
close(conn);
writetable(cell2table({'7'}),'log.txt','WriteVariableNames',false)
end
6 件のコメント
Kojiro Saito
2019 年 4 月 2 日
Could you add the following line in your function
which database
and confirm Database Toolbox function is added compiled application properly?
Adrien Corbin
2019 年 4 月 2 日
Kojiro Saito
2019 年 4 月 2 日
Add "which database" in the first line in function tampon.
Then enable log file by checking in "Create log file" in Application Compiler Window (please see Additional Runtime Settings document). So result of "which database" is written in a log file of the compiled application.
Adrien Corbin
2019 年 4 月 2 日
Kojiro Saito
2019 年 4 月 3 日
So, database command is pointing to the right m file.
How did you set up JDBC driver in MATLAB and how do you call compiled exe in Command Prompt?
Adrien Corbin
2019 年 4 月 4 日
編集済み: Adrien Corbin
2019 年 4 月 5 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Database Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!