How can I use sqlwrite with backgroundPool?
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am receiving real-time data and saving the data to a MS SQL Server database using sqlwrite with no problem. I want to run this on the backgroundPool to ensure the main thread remains responsive to user input. I have Parallel Computing Toolbox and a JDBC connection object that reads and writes to the MS SQL Server database with no issue.
However, when I create a parallel.pool.Constant object and pass it to parfeval, the connection object fails the check for a valid connection (~isopen(conn)) that is found in both sqlwrite (line 56) and fetch (line 69).
conn = database( ... );
bgConn = parallel.pool.Constant(conn);
f = parfeval(backgroundPool,@(c)isopen(c.Value),1,bgConn);
disp(['Bg Pool // ConnIsOpen: ' num2str(fetchOutputs(f))]);
returns
Bg Pool // ConnIsOpen: 0
If I try a function handle, I get a different error message.
fhConn = @()database( ... );
bgFhConn = parallel.pool.Constant(fhConn);
f = parfeval(backgroundPool,@(c)isopen(c.Value),1,bgFhConn);
disp(['Bg Pool // ConnIsOpen: ' num2str(fetchOutputs(f))]);
returns
One or more futures resulted in an error.
Caused by:
Unable to create parallel.pool.Constant on the workers.
Unable to resolve the name 'com.mathworks.jmi.ClassLoaderManager.getClassLoaderManager'.
How can I use parfeval to run sqlwrite? I see the same behaviour in both MATLAB 2024a and 2025a. Thanks for your help.
0 Kommentare
Antworten (1)
Raymond Norris
am 2 Okt. 2025 um 16:11
@Dave rather than creating the connection on the client side and passing it to each worker, take a look at createConnectionForPool - Initialize parallel pool using database connection - MATLAB. createConnectionForPool creates a connection for each worker in the pool.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Database Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!