From d5d23dde25e31a2d8d31778f488f57889af2c03a Mon Sep 17 00:00:00 2001
From: Bruce Momjian <bruce@momjian.us>
Date: Sat, 25 Nov 2000 04:32:12 +0000
Subject: [PATCH] Allow jdbc to return proper server version number

Anders Bengtsson
---
 .../org/postgresql/jdbc1/DatabaseMetaData.java   | 16 ++++++++--------
 .../org/postgresql/jdbc2/DatabaseMetaData.java   | 16 ++++++++--------
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java b/src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java
index b1f7e581bc6..56296d37b0f 100644
--- a/src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java
+++ b/src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java
@@ -167,19 +167,19 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
   /**
    * What is the version of this database product.
    *
-   * <p>Note that PostgreSQL 6.3 has a system catalog called pg_version - 
-   * however, select * from pg_version on any database retrieves
-   * no rows.
-   *
-   * <p>For now, we will return the version 6.3 (in the hope that we change
-   * this driver as often as we change the database)
-   *
    * @return the database version
    * @exception SQLException if a database access error occurs
    */
   public String getDatabaseProductVersion() throws SQLException
   {
-      return connection.this_driver.getVersion();
+	java.sql.ResultSet resultSet = connection.ExecSQL("select version()");
+	resultSet.next();
+
+	StringTokenizer versionParts = new StringTokenizer(resultSet.getString(1));
+	versionParts.nextToken(); /* "PostgreSQL" */
+	String versionNumber = versionParts.nextToken(); /* "X.Y.Z" */
+
+	return versionNumber;
   }
   
   /**
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java b/src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java
index 051a99c630d..c660022b44b 100644
--- a/src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java
+++ b/src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java
@@ -167,19 +167,19 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
   /**
    * What is the version of this database product.
    *
-   * <p>Note that PostgreSQL 6.3 has a system catalog called pg_version - 
-   * however, select * from pg_version on any database retrieves
-   * no rows.
-   *
-   * <p>For now, we will return the version 6.3 (in the hope that we change
-   * this driver as often as we change the database)
-   *
    * @return the database version
    * @exception SQLException if a database access error occurs
    */
   public String getDatabaseProductVersion() throws SQLException
   {
-      return connection.this_driver.getVersion();
+	java.sql.ResultSet resultSet = connection.ExecSQL("select version()");
+	resultSet.next();
+
+	StringTokenizer versionParts = new StringTokenizer(resultSet.getString(1));
+	versionParts.nextToken(); /* "PostgreSQL" */
+	String versionNumber = versionParts.nextToken(); /* "X.Y.Z" */
+
+	return versionNumber;
   }
   
   /**
-- 
GitLab