view m-toolbox/classes/+utils/@jmysql/dbconnTojconn.m @ 13:e05504b18072 database-connection-manager

Move more functions to utils.repository
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
line wrap: on
line source

% DBCONNTOJCONN convert a MATLAB database connection to a java db connection.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% DESCRIPTION: DBCONNTOJCONN convert a MATLAB database toolbox connection
%              to a java db connection.
%
% CALL:        jconn = utils.jmysql.dbconnTojconn(dbconn);
%
% INPUTS:
%              dbconn - a database toolbox connecton
% 
% OUTPUTS:     
%              jconn - a connection object like that returned from
%                     utils.jmysql.connect.
%
%
% VERSION:     $Id: dbconnTojconn.m,v 1.1 2009/07/28 06:46:09 hewitson Exp $
%
% HISTORY:     24-05-2007 M Hewitson
%                 Creation
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



function jconn = dbconnTojconn(conn)
  
  if nargin ~= 1 || ~isa(conn, 'database')
    error('### The first argument should be a database connection');
  end

  r = regexp(conn.URL, '//(.+)/', 'tokens');
  host = r{1};
  
  db   = conn.Instance;
  user = conn.UserName;
  
  jconn = utils.jmysql.connect(host, db, user, '');
  
  
  
end