Re: [postgis-users] compatibilité JDBC Postgis PostgreSQL
Jean-Pierre Quirion
jpquirion at yahoo.ca
Thu Mar 3 10:57:01 PST 2005
Hi Dominique,
--- Dominique Legendre a écrit :
> i am trying to write a Java/JDBC program for inserting new geometry in
> a table.
> I use postgis 1.0.0rc2 on PostreSQL 8.0.1 and my java program use 1.4.2
>
> My program works correcty the pg74.215.jdbc3 version of the posgres JDBC
> driver but fails with the postgresql-8.0.309.jdbc3 version.
> this is the error message:
> java.lang.NoSuchMethodError:
> org.postgresql.core.BaseConnection.getEncoding()Lorg/postgresql/core/Encoding;
as I have run in the same pitfall today, here the explanation (and solution):
If you download postgis 1.0.0 jdbc2 as source code and you compile it with the delivered ANT
build.xml, you get a jar file which contains two stub classes/interfaces (PGConnection for PG7.2
and org.postgresql.PGConnection for Postgres7.3+). These stubs are necessary only for compiling,
because during runtime you include your appropiate jar (postgresql-8.0-310.jdbc3.jar or
pg72jdbc2.jar) in the classpath. At runtime these stub classes do not bother if they are "hidden"
by the correct postgres classes.
As long as the jar file of postgres JDBC is in alphabetical order previous to the postgis.jar
file, everything works fine. With version 8 the postgres jar file has been renamed and is now
alphabetically behind the postgis jar and therefore the stubs are found instead of the real
class/interface! The stubs do not have the getEncoding() method and therefore we get this error.
Solution A: rename your postgresql-8.0-310.jdbc3.jar in pg8.0-310.jdbc3.jar or similar.
Solution B: generate a jar file without the stubs (I did it and it works.)
cu
Jean-Pierre
__________________________________________________________
Lèche-vitrine ou lèche-écran ?
magasinage.yahoo.ca
More information about the postgis-users
mailing list