Skip to content

Commit 2535fcd

Browse files
committed
From: Peter T Mount <patches@maidast.demon.co.uk>
This patch fixes the following: * Fixes minor bug found in DatabaseMetaData.getTables() where it doesn't handle default table types. * It now reports an error if the client opens a database using properties, and either the user or password properties are missing. This should make the recent problem with Servlets easier to find. * Commented out obsolete property in Driver.getPropertyInfo()
1 parent 83e637a commit 2535fcd

File tree

4 files changed

+31
-11
lines changed

4 files changed

+31
-11
lines changed

src/interfaces/jdbc/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Makefile for Java JDBC interface
55
#
66
# IDENTIFICATION
7-
# $Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/Makefile,v 1.5 1998/02/02 13:16:38 scrappy Exp $
7+
# $Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/Makefile,v 1.6 1998/02/09 03:22:30 scrappy Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -75,7 +75,8 @@ OBJS= postgresql/CallableStatement.class \
7575
postgresql/largeobject/LargeObject.class \
7676
postgresql/largeobject/LargeObjectManager.class \
7777
postgresql/util/PGobject.class \
78-
postgresql/util/PGtokenizer.class
78+
postgresql/util/PGtokenizer.class \
79+
postgresql/util/UnixCrypt.class
7980

8081
# If you have problems with the first line, try the second one.
8182
# This is needed when compiling under Solaris, as the solaris sh doesn't
@@ -120,6 +121,7 @@ postgresql/largeobject/LargeObject.class: postgresql/largeobject/LargeObject.jav
120121
postgresql/largeobject/LargeObjectManager.class: postgresql/largeobject/LargeObjectManager.java
121122
postgresql/util/PGobject.class: postgresql/util/PGobject.java
122123
postgresql/util/PGtokenizer.class: postgresql/util/PGtokenizer.java
124+
postgresql/util/UnixCrypt.class: postgresql/util/UnixCrypt.java
123125

124126
#######################################################################
125127
# These classes are in the example directory, and form the examples

src/interfaces/jdbc/postgresql/Connection.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ public Connection(String host, int port, Properties info, String database, Strin
139139
{
140140
//int len = STARTUP_LEN; // Length of a startup packet
141141

142+
// Throw an exception if the user or password properties are missing
143+
// This occasionally occurs when the client uses the properties version
144+
// of getConnection(), and is a common question on the email lists
145+
if(info.getProperty("user")==null)
146+
throw new SQLException("The user property is missing. It is mandatory.");
147+
if(info.getProperty("password")==null)
148+
throw new SQLException("The password property is missing. It is mandatory.")
149+
142150
this_driver = d;
143151
this_url = new String(url);
144152
PG_DATABASE = new String(database);

src/interfaces/jdbc/postgresql/DatabaseMetaData.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,6 +1615,10 @@ public java.sql.ResultSet getProcedureColumns(String catalog, String schemaPatte
16151615
*/
16161616
public java.sql.ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String types[]) throws SQLException
16171617
{
1618+
// Handle default value for types
1619+
if(types==null)
1620+
types = defaultTableTypes;
1621+
16181622
// the field descriptors for the new ResultSet
16191623
Field f[] = new Field[5];
16201624
ResultSet r; // ResultSet for the SQL query that we need to do
@@ -1687,6 +1691,12 @@ public java.sql.ResultSet getTables(String catalog, String schemaPattern, String
16871691
{"SYSTEM INDEX", "(relkind='i' and relname ~ '^pg_')"}
16881692
};
16891693

1694+
// These are the default tables, used when NULL is passed to getTables
1695+
// The choice of these provide the same behaviour as psql's \d
1696+
private static final String defaultTableTypes[] = {
1697+
"TABLE","INDEX","SEQUENCE"
1698+
};
1699+
16901700
/**
16911701
* Get the schema names available in this database. The results
16921702
* are ordered by schema name.

src/interfaces/jdbc/postgresql/Driver.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,16 @@ public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws
130130

131131
// naughty, but its best for speed. If anyone adds a property here, then
132132
// this _MUST_ be increased to accomodate them.
133-
DriverPropertyInfo d,dpi[] = new DriverPropertyInfo[1];
134-
int i=0;
133+
DriverPropertyInfo d,dpi[] = new DriverPropertyInfo[0];
134+
//int i=0;
135135

136-
dpi[i++] = d = new DriverPropertyInfo("auth",p.getProperty("auth","default"));
137-
d.description = "determines if password authentication is used";
138-
d.choices = new String[4];
139-
d.choices[0]="default"; // Get value from postgresql.auth property, defaults to trust
140-
d.choices[1]="trust"; // No password authentication
141-
d.choices[2]="password"; // Password authentication
142-
d.choices[3]="ident"; // Ident (RFC 1413) protocol
136+
//dpi[i++] = d = new DriverPropertyInfo("auth",p.getProperty("auth","default"));
137+
//d.description = "determines if password authentication is used";
138+
//d.choices = new String[4];
139+
//d.choices[0]="default"; // Get value from postgresql.auth property, defaults to trust
140+
//d.choices[1]="trust"; // No password authentication
141+
//d.choices[2]="password"; // Password authentication
142+
//d.choices[3]="ident"; // Ident (RFC 1413) protocol
143143

144144
return dpi;
145145
}

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