|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.postgresql.Driver
org.postgis.DriverWrapper
public class DriverWrapper
DriverWrapper
Wraps the PostGreSQL Driver to transparently add the PostGIS Object Classes.
This avoids the need of explicit addDataType() calls from the driver users
side.
This method currently works with J2EE DataSource implementations, and with
DriverManager framework.
Simply replace the "jdbc:postgresql:" with a "jdbc:postgresql_postGIS:" in
the jdbc URL.
When using the drivermanager, you need to initialize DriverWrapper instead of
(or in addition to) org.postgresql.Driver. When using a J2EE DataSource
implementation, set the driver class property in the datasource config, the
following works for jboss:
<driver-class>org.postgis.DriverWrapper</driver-class>
If you don't like or want to use the DriverWrapper, you have two
alternatives, see the README file.
Also note that the addDataType() methods known from earlier pgjdbc versions
are deprecated in pgjdbc 8.0, see the commented code variants in the
addGisTypes() method.
This wrapper always uses EWKT as canonical text representation, and thus
works against PostGIS 1.x servers as well as 0.x (tested with 0.8, 0.9 and
1.0).
DriverWrapperLW
,
DriverWrapperAutoprobe
Nested Class Summary | |
---|---|
protected static class |
DriverWrapper.TypesAdder
Base class for the three typewrapper implementations |
protected static class |
DriverWrapper.TypesAdder72
addGISTypes for V7.2 pgjdbc |
protected static class |
DriverWrapper.TypesAdder74
addGISTypes for V7.3 and V7.4 pgjdbc |
protected static class |
DriverWrapper.TypesAdder80
addGISTypes for V8.0 (and hopefully newer) pgjdbc |
Field Summary | |
---|---|
protected static java.util.logging.Logger |
logger
|
static java.lang.String |
POSTGIS_PROTOCOL
|
static java.lang.String |
POSTGRES_PROTOCOL
|
static java.lang.String |
REVISION
|
protected static DriverWrapper.TypesAdder |
ta72
|
protected static DriverWrapper.TypesAdder |
ta74
|
protected static DriverWrapper.TypesAdder |
ta80
|
protected DriverWrapper.TypesAdder |
typesAdder
|
Fields inherited from class org.postgresql.Driver |
---|
DEBUG, INFO, MAJORVERSION, MINORVERSION |
Constructor Summary | |
---|---|
DriverWrapper()
Default constructor. |
Method Summary | |
---|---|
boolean |
acceptsURL(java.lang.String url)
Check whether the driver thinks he can handle the given URL. |
static void |
addGISTypes(org.postgresql.PGConnection pgconn)
adds the JTS/PostGIS Data types to a PG 7.3+ Connection. |
static void |
addGISTypes72(org.postgresql.PGConnection pgconn)
adds the JTS/PostGIS Data types to a PG 7.2 Connection. |
static void |
addGISTypes80(org.postgresql.PGConnection pgconn)
adds the JTS/PostGIS Data types to a PG 8.0+ Connection. |
java.sql.Connection |
connect(java.lang.String url,
java.util.Properties info)
Creates a postgresql connection, and then adds the PostGIS data types to it calling addpgtypes() |
protected java.lang.String |
getProtoString()
|
protected static DriverWrapper.TypesAdder |
getTypesAdder(org.postgresql.Driver d)
|
static java.lang.String |
getVersion()
Returns our own CVS version plus postgres Version |
protected java.lang.String |
mangleURL(java.lang.String url)
Mangles the PostGIS URL to return the original PostGreSQL URL |
protected boolean |
useLW(java.sql.Connection result)
Do we have HexWKB as well known text representation - to be overridden by subclasses. |
Methods inherited from class org.postgresql.Driver |
---|
getLogLevel, getMajorVersion, getMinorVersion, getPropertyInfo, jdbcCompliant, makeSSL, notImplemented, setLogLevel, sslEnabled |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final java.util.logging.Logger logger
public static final java.lang.String POSTGRES_PROTOCOL
public static final java.lang.String POSTGIS_PROTOCOL
public static final java.lang.String REVISION
protected static DriverWrapper.TypesAdder ta72
protected static DriverWrapper.TypesAdder ta74
protected static DriverWrapper.TypesAdder ta80
protected DriverWrapper.TypesAdder typesAdder
Constructor Detail |
---|
public DriverWrapper() throws java.sql.SQLException
java.sql.SQLException
Method Detail |
---|
protected static DriverWrapper.TypesAdder getTypesAdder(org.postgresql.Driver d) throws java.sql.SQLException
java.sql.SQLException
public java.sql.Connection connect(java.lang.String url, java.util.Properties info) throws java.sql.SQLException
connect
in interface java.sql.Driver
connect
in class org.postgresql.Driver
url
- the URL of the database to connect toinfo
- a list of arbitrary tag/value pairs as connection arguments
java.sql.SQLException
- if a database access error occursDriver.connect(java.lang.String, java.util.Properties)
,
Driver
protected boolean useLW(java.sql.Connection result)
public boolean acceptsURL(java.lang.String url) throws java.sql.SQLException
acceptsURL
in interface java.sql.Driver
acceptsURL
in class org.postgresql.Driver
url
- the URL of the driver
java.sql.SQLException
- Passed through from the underlying PostgreSQL
driver, should not happen.Driver.acceptsURL(java.lang.String)
public static java.lang.String getVersion()
public static void addGISTypes(org.postgresql.PGConnection pgconn) throws java.sql.SQLException
java.sql.SQLException
public static void addGISTypes80(org.postgresql.PGConnection pgconn) throws java.sql.SQLException
java.sql.SQLException
public static void addGISTypes72(org.postgresql.PGConnection pgconn) throws java.sql.SQLException
java.sql.SQLException
protected java.lang.String mangleURL(java.lang.String url) throws java.sql.SQLException
java.sql.SQLException
protected java.lang.String getProtoString()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |