org.geotools.referencing.factory.epsg
Class PostgreDataSource

java.lang.Object
  extended byorg.postgresql.jdbc2.optional.BaseDataSource
      extended byorg.postgresql.jdbc2.optional.SimpleDataSource
          extended byorg.postgresql.jdbc3.Jdbc3SimpleDataSource
              extended byorg.geotools.referencing.factory.epsg.PostgreDataSource
All Implemented Interfaces:
DataSource, javax.sql.DataSource, javax.naming.Referenceable, java.io.Serializable

public class PostgreDataSource
extends org.postgresql.jdbc3.Jdbc3SimpleDataSource
implements DataSource

Connection to the EPSG database in PostgreSQL database engine using JDBC. The EPSG database can be downloaded from http://www.epsg.org. It should have been imported into a PostgreSQL database, which doesn't need to be on the local machine.

Connection parameters

The preferred way to specify connection parameters is through the JNDI interface. However, this datasource provides the following alternative as a convenience: if an {@value} file is found in current directory or in the user's home directory, then the following properties are fetch. Note that the default value may change in a future version if a public server become available.

Property Type Description Geotools Default
String PostgreSQL database server host name
String PostgreSQL database name
String The schema for the EPSG tables
int TCP port which the PostgreSQL database server is listening on
String User used to make database connections
String Password used to make database connections

The database version is given in the edition attribute of the authority. The postgreSQL database should be read only.

Just having this class accessible in the classpath, together with the registration in the directory, is suffisient to get a working EPSG authority factory backed by this database. Vendors can create a copy of this class, modify it and bundle it with their own distribution if they want to connect their users to an other database.

Since:
2.2
Version:
$Id: PostgreDataSource.java 17661 2006-01-18 07:55:11Z desruisseaux $
Author:
Didier Richard, Martin Desruisseaux
See Also:
Serialized Form

Field Summary
static java.lang.String CONFIGURATION_FILE
          The user configuration file.
 
Fields inherited from interface org.geotools.referencing.factory.epsg.DataSource
MAXIMUM_PRIORITY, MINIMUM_PRIORITY, NORMAL_PRIORITY
 
Constructor Summary
PostgreDataSource()
          Creates a new instance of this data source.
PostgreDataSource(java.lang.String server, java.lang.String database, java.lang.String schema, java.lang.String user, java.lang.String password)
          Creates a new instance of this data source with the specified default parameters.
 
Method Summary
 AbstractAuthorityFactory createFactory(Hints hints)
          Open a connection and creates an EPSG factory for it.
 int getPriority()
          Returns the priority for this data source.
 
Methods inherited from class org.postgresql.jdbc3.Jdbc3SimpleDataSource
createReference, getDescription
 
Methods inherited from class org.postgresql.jdbc2.optional.BaseDataSource
getConnection, getConnection, getDatabaseName, getLoginTimeout, getLogWriter, getPassword, getPortNumber, getReference, getServerName, getUser, readBaseObject, setDatabaseName, setLoginTimeout, setLogWriter, setPassword, setPortNumber, setServerName, setUser, writeBaseObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.sql.DataSource
getConnection, getConnection, getLoginTimeout, getLogWriter, setLoginTimeout, setLogWriter
 

Field Detail

CONFIGURATION_FILE

public static final java.lang.String CONFIGURATION_FILE
The user configuration file. This class search first for the first file found in the following directories:

See Also:
Constant Field Values
Constructor Detail

PostgreDataSource

public PostgreDataSource()
Creates a new instance of this data source.


PostgreDataSource

public PostgreDataSource(java.lang.String server,
                         java.lang.String database,
                         java.lang.String schema,
                         java.lang.String user,
                         java.lang.String password)
Creates a new instance of this data source with the specified default parameters. If a configuration file has been found, then the user setting will override the arguments supplied to this constructor.

Parameters:
server - The server name.
database - The database name.
schema - The schema name, or if none.
user - The user name.
password - The password.
Method Detail

getPriority

public int getPriority()
Returns the priority for this data source. This priority is set to a lower value than the AccessDataSource's one in order to give the priority to any "official" database installed locally by the user, when available.

Specified by:
getPriority in interface DataSource

createFactory

public AbstractAuthorityFactory createFactory(Hints hints)
                                       throws java.sql.SQLException
Open a connection and creates an EPSG factory for it.

Specified by:
createFactory in interface DataSource
Parameters:
hints - A map of hints, including the low-level factories to use for CRS creation.
Returns:
The EPSG factory using PostgreSQL syntax.
Throws:
java.sql.SQLException - if connection to the database failed.


Copyright © GeoTools. All Rights Reserved.