How can I use sqlwrite with backgroundPool?
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:
Error using parallel.pool.Constant/get.Value (line 188)
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.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:
Error using parallel.pool.Constant/get.Value (line 188)
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. 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:
Error using parallel.pool.Constant/get.Value (line 188)
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. backgroundpool, sqlwrite, fetch, database, jdbc MATLAB Answers — New Questions