Mercurial > hg > ltpda
diff 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 |
line wrap: on
line diff
--- a/m-toolbox/classes/+utils/@jmysql/connect.m Mon Dec 05 16:20:06 2011 +0100 +++ b/m-toolbox/classes/+utils/@jmysql/connect.m Mon Dec 05 16:20:06 2011 +0100 @@ -11,55 +11,15 @@ % in the LTPDA user preferences. % % CALL: conn = connect(hostname) -% conn = connect(hostname, dbname) -% conn = connect(hostname, dbname, dbuser, dbpass) +% conn = connect(hostname, database) +% conn = connect(hostname, database, username, password) % % VERSION: $Id: connect.m,v 1.13 2011/04/01 08:36:49 hewitson Exp $ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -function varargout = connect(varargin) - - dbuser = ''; - dbpass = ''; - dbhost = ''; - dbname = ''; +function conn = connect(varargin) + + conn = LTPDADatabaseConnectionManager().connect(varargin{:}); - if nargin == 1 - dbhost = varargin{1}; - elseif nargin == 2 - dbhost = varargin{1}; - dbname = varargin{2}; - elseif nargin == 3 - dbhost = varargin{1}; - dbname = varargin{2}; - elseif nargin == 4 - dbhost = varargin{1}; - dbname = varargin{2}; - dbuser = varargin{3}; - dbpass = varargin{4}; - elseif nargin == 5 - dbhost = varargin{1}; - dbname = varargin{2}; - dbuser = varargin{3}; - dbpass = varargin{4}; - end - - rm = LTPDARepositoryManager(); - conn = rm.findConnections(dbhost, dbname, dbuser, dbpass); - - if isempty(conn) - conn = rm.newConnection(dbhost, dbname, dbuser, dbpass); - end - - if ~isempty(dbpass) && isempty(char(conn.getPassword)) - conn.setPassword(dbpass) - end - - % If we have more than one matching connection, let the user choose. - if numel(conn) > 1 - conn = rm.manager.selectConnection([]); - end - - varargout{1} = conn(1); end