ネストされた 2 つの for ループ内で同じクエリを何度も実行するために、Matlab Database Toolbox を介して MySQL データベースに接続しています。各反復の後、次の警告が表示されます。
Warning: com.mathworks.toolbox.database.databaseConnect@26960369 is not serializable
In Import_Matrices_DOandT_julaugsept_inflow_nomettsed at 476
Warning: com.mysql.jdbc.Connection@6e544a45 is not serializable
In Import_Matrices_DOandT_julaugsept_inflow_nomettsed at 476
Warning: com.mathworks.toolbox.database.databaseConnect@26960369 not serializable
In Import_Matrices_DOandT_julaugsept_inflow_nomettsed at 476
Warning: com.mysql.jdbc.Connection@6e544a45 is not serializable
In Import_Matrices_DOandT_julaugsept_inflow_nomettsed at 476
私のコードは基本的に次のように構成されています。
%Server
host =
user =
password =
dbName =
%# JDBC parameters
jdbcString = sprintf('jdbc:mysql://%s/%s', host, dbName);
jdbcDriver = 'com.mysql.jdbc.Driver';
%# Create the database connection object
conn = database(dbName, user , password, jdbcDriver, jdbcString);
setdbprefs('DataReturnFormat', 'numeric');
%Loop
for SegmentNum=3:41;
for tl=1:15;
tic;
sqlquery=['giant string'];
results = fetch(conn, sqlquery);
(some code here that saves the results into a few variables)
save('inflow.mat');
end
end
time = toc
close(conn);
clear conn
最終的に、いくつかの反復の後、コードは次のエラーでクラッシュします。
Error using database/fetch (line 37)
Query execution was interrupted
Error in Import_Matrices_DOandT_julaugsept_inflow_nomettsed (line
466)
results = fetch(conn, sqlquery);
昨夜、25回の反復後にエラーが発生しました。合計で約 600 回の反復が必要ですが、25 回ごとにチェックし続ける必要はありません。データベース接続オブジェクトにメモリの問題が発生する可能性があると聞きました...維持する方法はありますか?私のコードは実行中ですか?