diff m-toolbox/classes/+utils/@jmysql/dbconnTojconn.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/m-toolbox/classes/+utils/@jmysql/dbconnTojconn.m	Wed Nov 23 19:22:13 2011 +0100
@@ -0,0 +1,43 @@
+% 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
+