[JDBC] Postgis example TestAutoregister is not working due to missinggetVersion() from pgjdbc community jar - Mailing list pgsql-jdbc

From Fahar Abbas
Subject [JDBC] Postgis example TestAutoregister is not working due to missinggetVersion() from pgjdbc community jar
Date
Msg-id CAJFwRrOkE2HsU8FitvEEb971d6XQRfSQJVi1AEsjBxziFGinvQ@mail.gmail.com
Whole thread Raw
Responses Re: [JDBC] Postgis example TestAutoregister is not working due tomissing getVersion() from pgjdbc community jar  (Dave Cramer <pg@fastcrypt.com>)
Re: Postgis example TestAutoregister is not working due tomissing getVersion() from pgjdbc community jar  (Dave Cramer <pg@fastcrypt.com>)
List pgsql-jdbc
Hi pgsql-jdbc community!

Steps of EDB PostgreSQL9.6  installers download from EnterpriseDB website.

------
1. Install JDK 7 on Linux 32 and Linux 64 and on mac install JDK 8
2. Install pgjdbc and postgis from (PostgreSQL) StackBuilder
3. Performs below commands from terminal:

For Linux:
------------
export JAVA_HOME=/usr/local/jdk1.7.0_51/bin/java
export PATH=/usr/local/jdk1.7.0_51/bin:$PATH
export
CLASSPATH=.:/opt/PostgreSQL/pgJDBC/postgresql-42.1.3.jre6.jar:/opt/PostgreSQL/9.6/PostGIS/java/jdbc/postgis-jdbc-2.1.7.2.jar:$CLASSPATH
export
CLASSPATH=.:/opt/PostgreSQL/pgJDBC/postgresql-42.1.3.jre7.jar:/opt/PostgreSQL/9.6/PostGIS/java/jdbc/postgis-jdbc-2.1.7.2.jar:$CLASSPATH

For MAC:
----------
export JAVA_HOME="/Library/Internet\
Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java"
export PATH="/Library/Internet\
Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/":$PATH
export
CLASSPATH=.:/Library/PostgreSQL/pgJDBC/postgresql-42.1.3.jar:/Library/PostgreSQL/9.6/PostGIS/java/jdbc/postgis-jdbc-2.1.7.2.jar:$CLASSPATH
export
CLASSPATH=.:/Library/PostgreSQL/pgJDBC/postgresql-42.1.3.jre6.jar:/Library/PostgreSQL/9.6/PostGIS/java/jdbc/postgis-jdbc-2.1.7.2.jar:$CLASSPATH
export
CLASSPATH=.:/Library/PostgreSQL/pgJDBC/postgresql-42.1.3.jre7.jar:/Library/PostgreSQL/9.6/PostGIS/java/jdbc/postgis-jdbc-2.1.7.2.jar:$CLASSPATH

4. Connect psql with postgres database.

5. <PG_HOME>/bin/psql -d postgres -p 5432

6. Create Postgis Extensions.

CREATE EXTENSION Postgis;
CREATE EXTENSION Postgis_topology;
CREATE EXTENSION fuzzystrmatch;
CREATE EXTENSION Postgis_tiger_geocoder;

7. Verify installed postgis extensions version through psql commands.

SELECT postgis_version();
SELECT postgis_full_version();
SELECT postgis_lib_build_date();
SELECT postgis_scripts_installed();

8. extract postgis-jdbc-2.1.7.2.jar file through jar xf
9. Now execute the example files and execute following query:

java examples/TestAutoregister
jdbc:postgresql://localhost:5432/postgres postgres postgres

Expected Result:
----------------
Postgis jar Example executed successfully.

Output:

java examples/TestAutoregister
jdbc:postgresql://localhost:5432/postgres postgres postgres
Testing proper auto-registration
Driver version: PostgreSQL 9.4 JDBC4.1 (build 1206)
Creating JDBC connection to jdbc:postgresql://localhost:5432/postgres
PostGIS Version: 2
PGgeometry successful!
Box3d successful!
Box2d successful!
Finished.
TestAutoregister.java finished without errors.

Actual Result:
--------------
java examples/TestAutoregister
jdbc:postgresql://localhost:5432/postgres postgres postgres
Testing proper auto-registration
Exception in thread "main" java.lang.NoSuchMethodError:
org.postgresql.Driver.getVersion()Ljava/lang/String;
at examples.TestAutoregister.main(TestAutoregister.java:64)
------------

After complete investigation, I observed that getVersion information
has been removed under community 42.jdbc.jar file however in
postgis-jdbc-2.1.7.2.jar, we are still using getVersion.

We(EDB PostgreSQL team) released last postgis-pg96-2.3.2-1 version on
15-Feb-2017 while community jdbc team removed getVersion from JDBC jar
file from PostgreSQL JDBC Driver 42.0.0 version on
19-Feb-2017.(https://jdbc.postgresql.org/)


Please note that we are shipping pgjdbc driver from
https://jdbc.postgresql.org/download.html while postgis jdbc jar under
this location: https://mvnrepository.com/artifact/net.postgis/postgis-jdbc/2.1.7.2

Please note that on 9.4.1212 version getVersion information is
available but not available on 42.jdbc.jar file

Kindly let us know if we are planning to fix that issue or not and we
will modify our postgis accordingly?

Kind Regards,
--
Fahar Abbas
QMG
EnterpriseDB Corporation


pgsql-jdbc by date:

Previous
From: rnveach
Date:
Subject: [JDBC] [pgjdbc/pgjdbc] 5f083d: style: remove deprecated maxLineLength fromLeftCu...
Next
From: Dave Cramer
Date:
Subject: Re: Postgis example TestAutoregister is not working due tomissing getVersion() from pgjdbc community jar