How can I use SQL/JDBC from compiled Matlab code(Generic COM component)?

1 view (last 30 days)
Hi, my matlab code successfully access MS-SQL via JDBC from the Matlab workbench.
I've done this via editing the classpath.txt and using javaaddpath function.
Both methods worked well. This is my abbreviated code.
function y = rtn(x)
javaaddpath('D:\DJ\sqljdbc4.jar')
conn = database('TEST','sa','abcd',...
'com.microsoft.sqlserver.jdbc.SQLServerDriver',...
'jdbc:sqlserver://test-db:1433;databaseName=TEST');
query = 'SELECT * FROM TEST_DATA';
result = fetch(conn,query);
y = x * result;
And then I made a Generic COM components and try and run them on two computers, which they have Matlab Compiler Runtime.
I used VBA as a client language to call COM. This is my VBA code.
Sub test()
Dim AAA As TEST.class1
Set AAA = New TEST.class1
x = 3
Call AAA.rtn(1, y, x)
Debug.Print y
Set AAA = Nothing
End Sub
The problem is that
one computer has no problem but the other computer didn't work.
The error message is
'-2147467259 (80004005)' Runtime Error
Error using database/fetch (line 23)
Unable to find JDBC driver
Error in => rtn.m at line 42
Both have Windows XP. There's no problem in jdbc url.
I installed the JDBC driver in both computers.
To adress the problem, I changed the MCR version, Office version and jdbc version. All didn't work for the latter computer and produce same error message.
I've worked on only this problem for whole week but no progress.
Thank you in advance.

Answers (0)

Community Treasure Hunt

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

Start Hunting!