[postgis-users] [jdbc][datasource] use postgis through JDBC in Spring
Markus Schaber
schabi at logix-tt.com
Fri Oct 20 01:37:12 PDT 2006
Hi, Nicolas,
Nicolas Delsaux wrote:
> Hi, is there anywhere a tutorial on PostGIS integration in JEE
> environments using containers like Spring or, even simpler,
> datasources instead of connections ?
> I suspect geotools provides a layer for connection, but will it remove
> the need for me to addDataTypes manually ?
You don't need to addDataTypes() manually if you either use pgjdbc 8.0
or newer, (this should automatically add those datatypes), or use
org.postgis.DriverWrapper instead of org.postgresql.Driver in your
datasource definition or the DriverManager call, and replace
"jdbc:postgresql:" with "jdbc:postgresql_postGIS" in the jdbc URL.
This all is explained briefly in the README in the PostGIS JDBC source.
Depending on your demands, there's a bunch of similar DriverClass /
DriverURL combinations:
org/postgis/java2d/Java2DWrapper jdbc:postgis_j2d:
// Read-Only, returns Java2D Objects
org/postgis/DriverWrapperLW jdbc:postgresql_lwgis:
// uses EWKB for sending, only works with PostGIS 1.X on the server side
org/postgis/DriverWrapper jdbc:postgresql_postGIS:
// uses EWKT for sending, compatible with PostGIS 0.X on the server side
org/postgis/DriverWrapperAutoprobe jdbc:postgresql_autogis:
// Queries the server for the installed PostGIS version on connection
setup, and choses EWKB/EWKT appropriately.
org/postgis/jts/JtsWrapper jdbc:postgres_jts:
// Uses JTS geometries for geometry datatype
org/postgis/jts/JtsGisWrapper jdbc:postgresql_JTS:
// Like above, but additionally supports box2d/box3d via org.postgis
classes.
The URL namings are somehow unfortunate currently, but should we ever
chose "better" ones, the old ones will continue to work.
HTH,
Markus
--
Markus Schaber | Logical Tracking&Tracing International AG
Dipl. Inf. | Software Development GIS
Fight against software patents in Europe! www.ffii.org
www.nosoftwarepatents.org
More information about the postgis-users
mailing list