% 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

