org.geotools.data.mysql
Class MySQLConnectionFactory

java.lang.Object
  extended byorg.geotools.data.mysql.MySQLConnectionFactory

public class MySQLConnectionFactory
extends java.lang.Object

Creates ConnectionPool objects for a certain MySQL database instance.

Author:
Gary Sheppard garysheppard@psu.edu

Constructor Summary
MySQLConnectionFactory(java.lang.String url)
          Creates a new MySQLConnectionFactory object from a MySQL database URL.
MySQLConnectionFactory(java.lang.String host, int port, java.lang.String instance)
          Creates a new MySQLConnectionFactory object from a host name, port number, and instance name.
MySQLConnectionFactory(java.lang.String host, java.lang.String instance)
          Creates a new MySQLConnectionFactory object from a host name and an instance name, using the normal MySQL port number of 3306.
 
Method Summary
 void free(ConnectionPool connectionPool)
           
 java.sql.Connection getConnection(java.util.Properties props)
          Creates a database connection method to initialize a given database for feature extraction with the given Properties.
 java.sql.Connection getConnection(java.lang.String user, java.lang.String password)
          Creates a database connection method to initialize a given database for feature extraction with the user and password params.
 ConnectionPool getConnectionPool()
          Creates and returns a MySQL ConnectionPool, or gets an existing ConnectionPool if one exists, based upon the username and password set in this MySQLConnectionFactory object.
 ConnectionPool getConnectionPool(java.lang.String username, java.lang.String password)
          Creates and returns a MySQL ConnectionPool, or gets an existing ConnectionPool if one exists, based upon the username and password parameters passed to this method.
 void setLogin(java.lang.String username, java.lang.String password)
          Sets the MySQL database login credentials.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MySQLConnectionFactory

public MySQLConnectionFactory(java.lang.String url)
Creates a new MySQLConnectionFactory object from a MySQL database URL. This is normally of the following format:

jdbc:mysql://:/

Parameters:
url - the MySQL database URL

MySQLConnectionFactory

public MySQLConnectionFactory(java.lang.String host,
                              int port,
                              java.lang.String instance)
Creates a new MySQLConnectionFactory object from a host name, port number, and instance name.

Parameters:
host - the MySQL database host
port - the port number for the MySQL database
instance - the MySQL database instance name

MySQLConnectionFactory

public MySQLConnectionFactory(java.lang.String host,
                              java.lang.String instance)
Creates a new MySQLConnectionFactory object from a host name and an instance name, using the normal MySQL port number of 3306.

Parameters:
host - the MySQL database host
instance - the MySQL database instance name
Method Detail

getConnectionPool

public ConnectionPool getConnectionPool(java.lang.String username,
                                        java.lang.String password)
                                 throws java.sql.SQLException
Creates and returns a MySQL ConnectionPool, or gets an existing ConnectionPool if one exists, based upon the username and password parameters passed to this method. This is shorthand for the following two calls:

connPool.setLogin(username, password);
connPool.getConnectionPool();

Parameters:
username - the MySQL username
password - the password corresponding to username
Returns:
a MySQL ConnectionPool object
Throws:
java.sql.SQLException - if an error occurs connecting to the MySQL database

getConnection

public java.sql.Connection getConnection(java.lang.String user,
                                         java.lang.String password)
                                  throws java.sql.SQLException
Creates a database connection method to initialize a given database for feature extraction with the user and password params.

Parameters:
user - the name of the user connect to connect to the pgsql db.
password - the password for the user.
Returns:
the sql Connection object to the database.
Throws:
java.sql.SQLException - if the postgis sql driver could not be found

getConnection

public java.sql.Connection getConnection(java.util.Properties props)
                                  throws java.sql.SQLException
Creates a database connection method to initialize a given database for feature extraction with the given Properties.

Parameters:
props - Should contain at a minimum the user and password. Additional properties, such as charSet, can also be added.
Returns:
the sql Connection object to the database.
Throws:
java.sql.SQLException - if the postgis sql driver could not be found

getConnectionPool

public ConnectionPool getConnectionPool()
                                 throws java.sql.SQLException
Creates and returns a MySQL ConnectionPool, or gets an existing ConnectionPool if one exists, based upon the username and password set in this MySQLConnectionFactory object. Please call setLogin before calling this method, or use getConnectionPool(String, String) instead.

Returns:
a MySQL ConnectionPool object
Throws:
java.sql.SQLException - if an error occurs connecting to the DB

setLogin

public void setLogin(java.lang.String username,
                     java.lang.String password)
Sets the MySQL database login credentials.

Parameters:
username - the username
password - the password

free

public void free(ConnectionPool connectionPool)


Copyright © GeoTools. All Rights Reserved.