Skip to content

Commit d5d23dd

Browse files
committed
Allow jdbc to return proper server version number
Anders Bengtsson
1 parent 9d5098c commit d5d23dd

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,19 +167,19 @@ public String getDatabaseProductName() throws SQLException
167167
/**
168168
* What is the version of this database product.
169169
*
170-
* <p>Note that PostgreSQL 6.3 has a system catalog called pg_version -
171-
* however, select * from pg_version on any database retrieves
172-
* no rows.
173-
*
174-
* <p>For now, we will return the version 6.3 (in the hope that we change
175-
* this driver as often as we change the database)
176-
*
177170
* @return the database version
178171
* @exception SQLException if a database access error occurs
179172
*/
180173
public String getDatabaseProductVersion() throws SQLException
181174
{
182-
return connection.this_driver.getVersion();
175+
java.sql.ResultSet resultSet = connection.ExecSQL("select version()");
176+
resultSet.next();
177+
178+
StringTokenizer versionParts = new StringTokenizer(resultSet.getString(1));
179+
versionParts.nextToken(); /* "PostgreSQL" */
180+
String versionNumber = versionParts.nextToken(); /* "X.Y.Z" */
181+
182+
return versionNumber;
183183
}
184184

185185
/**

src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,19 +167,19 @@ public String getDatabaseProductName() throws SQLException
167167
/**
168168
* What is the version of this database product.
169169
*
170-
* <p>Note that PostgreSQL 6.3 has a system catalog called pg_version -
171-
* however, select * from pg_version on any database retrieves
172-
* no rows.
173-
*
174-
* <p>For now, we will return the version 6.3 (in the hope that we change
175-
* this driver as often as we change the database)
176-
*
177170
* @return the database version
178171
* @exception SQLException if a database access error occurs
179172
*/
180173
public String getDatabaseProductVersion() throws SQLException
181174
{
182-
return connection.this_driver.getVersion();
175+
java.sql.ResultSet resultSet = connection.ExecSQL("select version()");
176+
resultSet.next();
177+
178+
StringTokenizer versionParts = new StringTokenizer(resultSet.getString(1));
179+
versionParts.nextToken(); /* "PostgreSQL" */
180+
String versionNumber = versionParts.nextToken(); /* "X.Y.Z" */
181+
182+
return versionNumber;
183183
}
184184

185185
/**

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy