Skip to content

Commit 32c3db0

Browse files
author
Dave Cramer
committed
patch from Oliver Jowett to implement some of the jdbc3 methods
1 parent 865429e commit 32c3db0

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

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

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import org.postgresql.util.*;
1515

1616

17-
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.14 2003/02/04 09:20:08 barry Exp $
17+
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.15 2003/02/05 11:12:39 davec Exp $
1818
* This class defines methods of the jdbc1 specification. This class is
1919
* extended by org.postgresql.jdbc2.AbstractJdbc2Connection which adds the jdbc2
2020
* methods. The real Connection class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Connection
@@ -1159,6 +1159,56 @@ public String getDBVersionNumber()
11591159
return dbVersionNumber;
11601160
}
11611161

1162+
// Parse a "dirty" integer surrounded by non-numeric characters
1163+
private static int integerPart(String dirtyString)
1164+
{
1165+
int start, end;
1166+
1167+
for (start = 0; start < dirtyString.length() && !Character.isDigit(dirtyString.charAt(start)); ++start)
1168+
;
1169+
1170+
for (end = start; end < dirtyString.length() && Character.isDigit(dirtyString.charAt(end)); ++end)
1171+
;
1172+
1173+
if (start == end)
1174+
return 0;
1175+
1176+
return Integer.parseInt(dirtyString.substring(start, end));
1177+
}
1178+
1179+
/*
1180+
* Get server major version
1181+
*/
1182+
public int getServerMajorVersion()
1183+
{
1184+
try
1185+
{
1186+
StringTokenizer versionTokens = new StringTokenizer(dbVersionNumber, "."); // aaXbb.ccYdd
1187+
return integerPart(versionTokens.nextToken()); // return X
1188+
}
1189+
catch (NoSuchElementException e)
1190+
{
1191+
return 0;
1192+
}
1193+
}
1194+
1195+
/*
1196+
* Get server minor version
1197+
*/
1198+
public int getServerMinorVersion()
1199+
{
1200+
try
1201+
{
1202+
StringTokenizer versionTokens = new StringTokenizer(dbVersionNumber, "."); // aaXbb.ccYdd
1203+
versionTokens.nextToken(); // Skip aaXbb
1204+
return integerPart(versionTokens.nextToken()); // return Y
1205+
}
1206+
catch (NoSuchElementException e)
1207+
{
1208+
return 0;
1209+
}
1210+
}
1211+
11621212
/**
11631213
* Is the server we are connected to running at least this version?
11641214
* This comparison method will fail whenever a major or minor version

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