Package org.postgis.jts

## Class JtsWrapper

- java.lang.Object
- - org.postgresql.Driver
  - - org.postgis.jts.JtsWrapper

All Implemented Interfaces:
  `Driver`

    public class JtsWrapper
    extends org.postgresql.Driver

JtsWrapper Wraps the PostGreSQL Driver to add the JTS/PostGIS Object Classes. This method currently works with J2EE DataSource implementations, and with DriverManager framework. Simply replace the "jdbc:postgresql:" with a "jdbc:postgres_jts:" in the jdbc URL. When using the drivermanager, you need to initialize JtsWrapper 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.jts.PostGisWrapper</driver-class>

Author:
  markus.schaber@logix-tt.com

### Field Summary

Fields
`protected static Logger` `logger`
`static String` `REVISION`

### Constructor Summary

Constructors
`JtsWrapper()`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`boolean` `acceptsURL​(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 Connection.
`Connection` `connect​(String url, Properties info)` Creates a postgresql connection, and then adds the JTS GIS data types to it calling addpgtypes()
`int` `getMajorVersion()` Gets the underlying drivers major version number
`int` `getMinorVersion()` Get the underlying drivers minor version number
`static String` `getVersion()` Returns our own CVS version plus postgres Version
`static String` `mangleURL​(String url)` Mangles the PostGIS URL to return the original PostGreSQL URL

### Methods inherited from class org.postgresql.Driver

`deregister, getParentLogger, getPropertyInfo, getSharedTimer, isRegistered, jdbcCompliant, notImplemented, parseURL, register`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### logger

    protected static final Logger logger

#### REVISION

    public static final String REVISION

See Also:
  Constant Field Values

### Constructor Detail

#### JtsWrapper

    public JtsWrapper()

### Method Detail

#### connect

    public Connection connect​(String url,
                              Properties info)
                       throws SQLException

Creates a postgresql connection, and then adds the JTS GIS data types to it calling addpgtypes()

Specified by:
  `connect` in interface `Driver`
Overrides:
  `connect` in class `org.postgresql.Driver`
Parameters:
  `url` - the URL of the database to connect to
  `info` - a list of arbitrary tag/value pairs as connection arguments
Returns:
  a connection to the URL or null if it isnt us
Throws:
  `SQLException` - if a database access error occurs
See Also:
  `Driver.connect(java.lang.String, java.util.Properties)`, `Driver`

#### addGISTypes

    public static void addGISTypes​(org.postgresql.PGConnection pgconn)
                            throws SQLException

Adds the JTS/PostGIS Data types to a PG Connection.

Parameters:
  `pgconn` - The PGConnection object to add the types to
Throws:
  `SQLException` - when an SQLException occurs

#### mangleURL

    public static String mangleURL​(String url)
                            throws SQLException

Mangles the PostGIS URL to return the original PostGreSQL URL

Parameters:
  `url` - String containing the url to be "mangled"
Returns:
  "mangled" string
Throws:
  `SQLException` - when a SQLException occurs

#### acceptsURL

    public boolean acceptsURL​(String url)

Check whether the driver thinks he can handle the given URL.

Specified by:
  `acceptsURL` in interface `Driver`
Overrides:
  `acceptsURL` in class `org.postgresql.Driver`
Parameters:
  `url` - the URL of the driver
Returns:
  true if this driver accepts the given URL
See Also:
  `Driver.acceptsURL(java.lang.String)`

#### getMajorVersion

    public int getMajorVersion()

Gets the underlying drivers major version number

Specified by:
  `getMajorVersion` in interface `Driver`
Overrides:
  `getMajorVersion` in class `org.postgresql.Driver`
Returns:
  the drivers major version number

#### getMinorVersion

    public int getMinorVersion()

Get the underlying drivers minor version number

Specified by:
  `getMinorVersion` in interface `Driver`
Overrides:
  `getMinorVersion` in class `org.postgresql.Driver`
Returns:
  the drivers minor version number

#### getVersion

    public static String getVersion()

Returns our own CVS version plus postgres Version

Returns:
  String representation of the version