org.geotools.data.geometryless
Class JDBCConnectionFactory

java.lang.Object
  extended byorg.geotools.data.geometryless.JDBCConnectionFactory

public class JDBCConnectionFactory
extends java.lang.Object

Creates ConnectionPool objects for a certain JDBC database instance.

Author:
Rob Atkinson rob@socialchange.net.NOSPAM.au, Gary Sheppard garysheppard@psu.edu

Constructor Summary
JDBCConnectionFactory(java.lang.String url, java.lang.String driver)
          Creates a new JDBCConnectionFactory object from a specified database URL.
 
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 ConnectionPool, or gets an existing ConnectionPool if one exists, based upon the username and password set in this JDBCConnectionFactory object.
 ConnectionPool getConnectionPool(java.lang.String username, java.lang.String password)
          Creates and returns a JDBC ConnectionPool, or gets an existing ConnectionPool if one exists, based upon the username and password parameters passed to this method.
 void setCharSet(java.lang.String charSet)
          Sets a different character set for the postgis driver to use.
 void setLogin(java.lang.String username, java.lang.String password)
          Sets the JDBC database login credentials.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDBCConnectionFactory

public JDBCConnectionFactory(java.lang.String url,
                             java.lang.String driver)
Creates a new JDBCConnectionFactory object from a specified database URL. This is the only constructor supported since there is significant variability in implementation syntax

jdbc:mysql://:/

Parameters:
url - the JDBC database URL
Method Detail

getConnectionPool

public ConnectionPool getConnectionPool(java.lang.String username,
                                        java.lang.String password)
                                 throws java.sql.SQLException
Creates and returns a JDBC 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 JDBC username
password - the password corresponding to username
Returns:
a JDBC ConnectionPool object
Throws:
java.sql.SQLException - if an error occurs connecting to the JDBC 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 db.
password - the password for the user.
Returns:
the sql Connection object to the database.
Throws:
java.sql.SQLException - if the configured 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 ConnectionPool, or gets an existing ConnectionPool if one exists, based upon the username and password set in this JDBCConnectionFactory object. Please call setLogin before calling this method, or use getConnectionPool(String, String) instead.

Returns:
a 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 JDBC database login credentials.

Parameters:
username - the username
password - the password

free

public void free(ConnectionPool connectionPool)

setCharSet

public void setCharSet(java.lang.String charSet)
Sets a different character set for the postgis driver to use.

Parameters:
charSet - the string of a valid charset name.


Copyright © GeoTools. All Rights Reserved.