Mercurial > hg > ltpda
comparison m-toolbox/classes/+utils/@jmysql/connect.m @ 16:91f21a0aab35 database-connection-manager
Update utils.jquery
* * *
Update utils.jmysql.getsinfo
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Mon, 05 Dec 2011 16:20:06 +0100 |
parents | f0afece42f48 |
children |
comparison
equal
deleted
inserted
replaced
15:ce3fbb7ebe71 | 16:91f21a0aab35 |
---|---|
9 % not in the utility, the user is prompted for the missing informations. | 9 % not in the utility, the user is prompted for the missing informations. |
10 % Credentials are set to expire and to be entered again after a time defined | 10 % Credentials are set to expire and to be entered again after a time defined |
11 % in the LTPDA user preferences. | 11 % in the LTPDA user preferences. |
12 % | 12 % |
13 % CALL: conn = connect(hostname) | 13 % CALL: conn = connect(hostname) |
14 % conn = connect(hostname, dbname) | 14 % conn = connect(hostname, database) |
15 % conn = connect(hostname, dbname, dbuser, dbpass) | 15 % conn = connect(hostname, database, username, password) |
16 % | 16 % |
17 % VERSION: $Id: connect.m,v 1.13 2011/04/01 08:36:49 hewitson Exp $ | 17 % VERSION: $Id: connect.m,v 1.13 2011/04/01 08:36:49 hewitson Exp $ |
18 % | 18 % |
19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
20 | 20 |
21 function varargout = connect(varargin) | 21 function conn = connect(varargin) |
22 | |
23 conn = LTPDADatabaseConnectionManager().connect(varargin{:}); | |
22 | 24 |
23 dbuser = ''; | |
24 dbpass = ''; | |
25 dbhost = ''; | |
26 dbname = ''; | |
27 | |
28 if nargin == 1 | |
29 dbhost = varargin{1}; | |
30 elseif nargin == 2 | |
31 dbhost = varargin{1}; | |
32 dbname = varargin{2}; | |
33 elseif nargin == 3 | |
34 dbhost = varargin{1}; | |
35 dbname = varargin{2}; | |
36 elseif nargin == 4 | |
37 dbhost = varargin{1}; | |
38 dbname = varargin{2}; | |
39 dbuser = varargin{3}; | |
40 dbpass = varargin{4}; | |
41 elseif nargin == 5 | |
42 dbhost = varargin{1}; | |
43 dbname = varargin{2}; | |
44 dbuser = varargin{3}; | |
45 dbpass = varargin{4}; | |
46 end | |
47 | |
48 rm = LTPDARepositoryManager(); | |
49 conn = rm.findConnections(dbhost, dbname, dbuser, dbpass); | |
50 | |
51 if isempty(conn) | |
52 conn = rm.newConnection(dbhost, dbname, dbuser, dbpass); | |
53 end | |
54 | |
55 if ~isempty(dbpass) && isempty(char(conn.getPassword)) | |
56 conn.setPassword(dbpass) | |
57 end | |
58 | |
59 % If we have more than one matching connection, let the user choose. | |
60 if numel(conn) > 1 | |
61 conn = rm.manager.selectConnection([]); | |
62 end | |
63 | |
64 varargout{1} = conn(1); | |
65 end | 25 end |