Re: Postgis example TestAutoregister is not working due tomissing getVersion() from pgjdbc community jar - Mailing list pgsql-jdbc

From Dave Cramer
Subject Re: Postgis example TestAutoregister is not working due tomissing getVersion() from pgjdbc community jar
Date
Msg-id CADK3HH+hjrsBB3+0ku3v4R8HiqV97gHAm8fPtR6vStAt9JYJ7w@mail.gmail.com
Whole thread Raw
In response to [JDBC] Postgis example TestAutoregister is not working due to missinggetVersion() from pgjdbc community jar  (Fahar Abbas <fahar.abbas@enterprisedb.com>)
Responses Re: Postgis example TestAutoregister is not working due tomissing getVersion() from pgjdbc community jar  (Fahar Abbas <fahar.abbas@enterprisedb.com>)
List pgsql-jdbc
What do you need getVersion() for ?

Note there are:

@Override
public int getMajorVersion() {
return org.postgresql.util.DriverInfo.MAJOR_VERSION;
}

@Override
public int getMinorVersion() {
return org.postgresql.util.DriverInfo.MINOR_VERSION;
}



On 3 August 2017 at 21:44, Fahar Abbas <fahar.abbas@enterprisedb.com> wrote:
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


--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc

pgsql-jdbc by date:

Previous
From: Fahar Abbas
Date:
Subject: [JDBC] Postgis example TestAutoregister is not working due to missinggetVersion() from pgjdbc community jar
Next
From: Fahar Abbas
Date:
Subject: Re: [JDBC] Postgis example TestAutoregister is not working due tomissing getVersion() from pgjdbc community jar