我通過Matlab數據庫工具箱連接到MySQL數據庫,以便在2個嵌套for循環內一遍又一遍地運行相同的查詢。每次迭代後,我得到這樣的警告:Matlab數據庫工具箱 - 警告:[email protected]不可序列化
Warning: [email protected] is not serializable
In Import_Matrices_DOandT_julaugsept_inflow_nomettsed at 476
Warning: [email protected] is not serializable
In Import_Matrices_DOandT_julaugsept_inflow_nomettsed at 476
Warning: [email protected] not serializable
In Import_Matrices_DOandT_julaugsept_inflow_nomettsed at 476
Warning: [email protected] 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次都檢查一次。我聽說數據庫連接對象可能存在內存問題......有沒有辦法保留我的代碼運行?
是否有更多最後提供的錯誤陳述? – PearsonArtPhoto
是的,我不記得保存它,但它在fetch()命令上出錯。 – Amy
如果你可以再次運行它,併發布整個錯誤,這將有相當大的幫助。 – PearsonArtPhoto