-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConnect2DBH.m
More file actions
44 lines (40 loc) · 1009 Bytes
/
Connect2DBH.m
File metadata and controls
44 lines (40 loc) · 1009 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Connect to ISDAT DBH using new matlab interfaces
%
% Author: Reine Gill
% Input: Host name
% and list of ports to try!
%
% Return code: DB > 0 if successfull
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function DB=Connect2DBH(name,ports)
DB=0;
pind=1;
% Connect to ISDAT dbh
% Open data base, trying first port
clear lasterr;
disp(['Connecting to ISDAT dbh on host:',name]);
disp(['Using port:',num2str(ports(pind))]);
try
DB = Mat_DbOpen([name,':',num2str(ports(pind))]);
catch
lasterr
end
% Trying orther ports
while(strcmp(lasterr,'MAT_DBOPEN error.') && pind<length(ports))
pind=pind+1;
disp(['Connecting to ISDAT dbh on host:',name]);
disp(['Using port:',num2str(ports(pind))]);
% Open data base
try
DB = Mat_DbOpen([name,':',num2str(ports(pind))]);
catch
lasterr
end
end
if(strcmp(lasterr,'MAT_DBOPEN error.'))
disp('Failed to connect to dbh');
exit;
end