org.geotools.data.postgis
Class PostgisConnectionFactory

java.lang.Object
  extended byorg.geotools.data.postgis.PostgisConnectionFactory

public class PostgisConnectionFactory
extends java.lang.Object

Shell for JDBC transactions of all types. This creates connections for the postgis datasource to make its transactions. To create a PostgisDataSource, create a PostgisConnectionFactory, then call getConnection(), and pass that connection to the PostgisDataSource constructor.

Version:
$Id: PostgisConnectionFactory.java 17700 2006-01-22 23:30:39Z desruisseaux $
Author:
Rob Hranac, Vision for New York, Chris Holmes, TOPP
Task:
REVISIT: connection pooling, implementing java.sql.Datasource. I removed the implementing because that class should be provided by the vendor, not a hack on top of DriverManager. The only problem is that we can't use the postgres one directly, because it doesn't allow you to set the charset, which some of our users need.

Constructor Summary
PostgisConnectionFactory(java.lang.String host, int port, java.lang.String dbName)
          Constructor with all internal database driver classes, driver paths and database types.
PostgisConnectionFactory(java.lang.String host, java.lang.String port, java.lang.String dbName)
          Constructor with all internal database driver classes, driver paths and database types.
 
Method Summary
 void free(ConnectionPool connectionPool)
           
 java.sql.Connection getConnection()
          Creates a database connection method to initialize a given database for feature extraction using the set username and password.
 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()
           
 ConnectionPool getConnectionPool(java.lang.String user, java.lang.String pass)
           
 void setLogin(java.lang.String user, java.lang.String password)
          Creates a database connection method to initialize a given database for feature extraction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PostgisConnectionFactory

public PostgisConnectionFactory(java.lang.String host,
                                java.lang.String port,
                                java.lang.String dbName)
Constructor with all internal database driver classes, driver paths and database types.

Parameters:
host - The name or ip address of the computer where the postgis database is installed.
port - The port to connect on; 5432 is generally the postgres default.
dbName - The name of the pgsql database that holds the tables of the feature types that will be used by PostgisDataSource.

PostgisConnectionFactory

public PostgisConnectionFactory(java.lang.String host,
                                int port,
                                java.lang.String dbName)
Constructor with all internal database driver classes, driver paths and database types.

Parameters:
host - The name or ip address of the computer where the postgis database is installed.
port - The port to connect on; 5432 is generally the postgres default.
dbName - The name of the pgsql database that holds the tables of the feature types that will be used by PostgisDataSource.
Method Detail

setLogin

public void setLogin(java.lang.String user,
                     java.lang.String password)
Creates a database connection method to initialize a given database for feature extraction.

Parameters:
user - the name of the user connect to connect to the pgsql db.
password - the password for the user.

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
Creates a database connection method to initialize a given database for feature extraction using the set username and password.

Returns:
the sql Connection object to the database.
Throws:
java.sql.SQLException - if the postgres driver could not be found

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

getConnectionPool

public ConnectionPool getConnectionPool(java.lang.String user,
                                        java.lang.String pass)
                                 throws java.sql.SQLException
Throws:
java.sql.SQLException

getConnectionPool

public ConnectionPool getConnectionPool()
                                 throws java.sql.SQLException
Throws:
java.sql.SQLException

free

public void free(ConnectionPool connectionPool)

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


Copyright © GeoTools. All Rights Reserved.