re-attempt DB fetch connection

This commit is contained in:
Silas Oettinghaus
2025-07-10 13:32:25 +02:00
parent eed71b5610
commit 09d9e5011c

View File

@@ -43,8 +43,8 @@ classdef DBHandler < handle
elseif options.type == "mysql" elseif options.type == "mysql"
% datasource = "jdbc:mysql://134.245.243.254:3306/labor"; % datasource = "jdbc:mysql://134.245.243.254:3306/labor";
obj.conn = database( ... obj.conn = database( ...
string(obj.dataBase), ... % Database name string(obj.dataBase), ... % Database name
@@ -578,10 +578,28 @@ classdef DBHandler < handle
execute(obj.conn, query); execute(obj.conn, query);
end end
function answer = fetch(obj,query)
answer = fetch(obj.conn,query); function answer = fetch(obj, query)
maxFast = 20; maxSlow = 30;
for attempt = 1:maxSlow
try
answer = fetch(obj.conn, query);
return
catch ME
if attempt < maxFast
pause(1)
else
pause(10)
end
lastErr = ME;
end
end
pause(60)
error('Database fetch failed after %d attempts:\n%s', maxSlow, lastErr.getReport())
end end
function [result,query] = queryDB(obj, filterParams, selectedFields) function [result,query] = queryDB(obj, filterParams, selectedFields)
% getPathsWithFlexibleFilter Retrieves values from Runs table with flexible filtering % getPathsWithFlexibleFilter Retrieves values from Runs table with flexible filtering
% and lets the user select which fields to include in the SELECT statement. % and lets the user select which fields to include in the SELECT statement.