re-attempt DB fetch connection
This commit is contained in:
@@ -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.
|
||||||
|
|||||||
Reference in New Issue
Block a user