It possible to compile out a .dll with database toolbox function inside?

조회 수: 2 (최근 30일)
teresa
teresa 2011년 10월 28일
I have an application that works perfectly in MATLAB but when compiled as a c sharp dll does not...
function doModel(address,port,dbname,user,password,table,startingdate, endate)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%function doModel(address,port,db,user,password,table,startingdate,endate)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Input Parameters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% address : database internet protocol address (ex: localhost,XXX.XXX.XXX.XXX...)
% port : internet port (ex: 1433)
% db : database name
% user : user with permission
% password: password for the user with permission
% table : database table
% startingdate : start date index for trainnign data selection
% enddate : end date index for trainning data selection
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Output Parameters
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% model.mat : file with databasedata
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%init database toolbox
javaaddpath('sqljdbc4.jar');
logintimeout(5,'com.microsoft.sqlserver.jdbc.SQLServerDriver');
%start database connection
driver = 'com.microsoft.sqlserver.jdbc.SQLServerDriver';
url = strcat('jdbc:sqlserver://',address,':',port,';database= ',dbname);
conn=database(dbname,user,password,driver,url);
setdbprefs('DataReturnFormat','cellarray');
%select Data from Table in Database where date is between startingdate and
%enddate
%colnames ={'Date','PowerConsumed','WorkingDay','Temperature','Rain'};
sqlquery = ['select * from ',dbname,'.dbo.',table,' where Date >=''',startingdate,''' and Date<=''',endate,''''];
curs = fetch(conn, sqlquery);
close(conn);
TimeMatrixString = curs(:,1);
TotalPower = curs(:,2);
save data.mat TimeMatrixString TotalPower;
Regards.
  댓글 수: 1
Kaustubha Govind
Kaustubha Govind 2011년 10월 28일
The Database Toolbox is supported with MATLAB Compiler (http://www.mathworks.com/products/compiler/compiler_support.html). You probably need to debug the issue to see what the error is. Try printing the conn.Message field from your MATLAB function - it is empty when the database command is successful.

댓글을 달려면 로그인하십시오.

답변 (1개)

Titus Edelhofer
Titus Edelhofer 2011년 10월 28일
Hi,
I guess you will need to add the sqljdbc4.jar statically, i.e., to your classpath.txt. On the deployment machine put the classpath.txt in the directory where the dll is as well.
Titus
  댓글 수: 2
teresa
teresa 2011년 10월 28일
Hi Titus,
Could you explain in more detail how to add classpath to my deployment?
Regards.
Titus Edelhofer
Titus Edelhofer 2011년 10월 31일
Hi Francesc,
you need to edit classpath.txt which is matlabroot/toolbox/local/classpath.txt on your development machine and mcrroot/toolbox/local/classpath.txt on the deployment machine (where mcrroot is where you installed the MCR using MCRInstaller, something like c:\program files\Matlab Compiler Runtime\v714
Titus

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB Compiler SDK에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by