]> granicus.if.org Git - postgresql/commitdiff
From: Peter T Mount <patches@maidast.demon.co.uk>
authorMarc G. Fournier <scrappy@hub.org>
Mon, 9 Feb 1998 03:22:41 +0000 (03:22 +0000)
committerMarc G. Fournier <scrappy@hub.org>
Mon, 9 Feb 1998 03:22:41 +0000 (03:22 +0000)
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()

src/interfaces/jdbc/Makefile
src/interfaces/jdbc/postgresql/Connection.java
src/interfaces/jdbc/postgresql/DatabaseMetaData.java
src/interfaces/jdbc/postgresql/Driver.java

index 44a9ca32903d95ee628d6f4048363ec7dab2b201..d7ad13ff08c33adaaa71825565a854cfff8cf1f7 100644 (file)
@@ -4,7 +4,7 @@
 #    Makefile for Java JDBC interface
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/Makefile,v 1.5 1998/02/02 13:16:38 scrappy Exp $
+#    $Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/Makefile,v 1.6 1998/02/09 03:22:30 scrappy Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -75,7 +75,8 @@ OBJS= postgresql/CallableStatement.class \
        postgresql/largeobject/LargeObject.class \
        postgresql/largeobject/LargeObjectManager.class \
        postgresql/util/PGobject.class \
-       postgresql/util/PGtokenizer.class
+       postgresql/util/PGtokenizer.class \
+       postgresql/util/UnixCrypt.class
 
 # If you have problems with the first line, try the second one.
 # 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
 postgresql/largeobject/LargeObjectManager.class: postgresql/largeobject/LargeObjectManager.java
 postgresql/util/PGobject.class:                postgresql/util/PGobject.java
 postgresql/util/PGtokenizer.class:     postgresql/util/PGtokenizer.java
+postgresql/util/UnixCrypt.class:       postgresql/util/UnixCrypt.java
 
 #######################################################################
 # These classes are in the example directory, and form the examples
index 074a3d5579e8cd717ce247cabf813a222345fdf4..8dd980e2f063cc12f2fc5add13dab2f7247f8f17 100644 (file)
@@ -139,6 +139,14 @@ public class Connection implements java.sql.Connection
   {
     //int len = STARTUP_LEN;   // Length of a startup packet
     
+    // Throw an exception if the user or password properties are missing
+    // This occasionally occurs when the client uses the properties version
+    // of getConnection(), and is a common question on the email lists
+    if(info.getProperty("user")==null)
+      throw new SQLException("The user property is missing. It is mandatory.");
+    if(info.getProperty("password")==null)
+      throw new SQLException("The password property is missing. It is mandatory.")
+    
     this_driver = d;
     this_url = new String(url);
     PG_DATABASE = new String(database);
index 47c257e78241f30c9b08e770d0b2d9cb7192d4cb..d717218c8f8f0a67c38d0d522ae228bb95b5a1af 100644 (file)
@@ -1615,6 +1615,10 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
    */
   public java.sql.ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String types[]) throws SQLException
   {
+    // Handle default value for types
+    if(types==null)
+      types = defaultTableTypes;
+    
     // the field descriptors for the new ResultSet
     Field f[] = new Field[5];
     ResultSet r;       // ResultSet for the SQL query that we need to do
@@ -1687,6 +1691,12 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
     {"SYSTEM INDEX",   "(relkind='i' and relname ~ '^pg_')"}
   };
   
+  // These are the default tables, used when NULL is passed to getTables
+  // The choice of these provide the same behaviour as psql's \d
+  private static final String defaultTableTypes[] = {
+    "TABLE","INDEX","SEQUENCE"
+  };
+  
   /**
    * Get the schema names available in this database.  The results
    * are ordered by schema name.
index 4b1772c88efae0d06a01ff93545a77e1334e2fed..c8ef8b9a15ab789ff814570a8eae3d80ece3ab36 100644 (file)
@@ -130,16 +130,16 @@ public class Driver implements java.sql.Driver
     
     // naughty, but its best for speed. If anyone adds a property here, then
     // this _MUST_ be increased to accomodate them.
-    DriverPropertyInfo d,dpi[] = new DriverPropertyInfo[1];
-    int i=0;
+    DriverPropertyInfo d,dpi[] = new DriverPropertyInfo[0];
+    //int i=0;
     
-    dpi[i++] = d = new DriverPropertyInfo("auth",p.getProperty("auth","default"));
-    d.description = "determines if password authentication is used";
-    d.choices = new String[4];
-    d.choices[0]="default";    // Get value from postgresql.auth property, defaults to trust
-    d.choices[1]="trust";      // No password authentication
-    d.choices[2]="password";   // Password authentication
-    d.choices[3]="ident";      // Ident (RFC 1413) protocol
+    //dpi[i++] = d = new DriverPropertyInfo("auth",p.getProperty("auth","default"));
+    //d.description = "determines if password authentication is used";
+    //d.choices = new String[4];
+    //d.choices[0]="default";  // Get value from postgresql.auth property, defaults to trust
+    //d.choices[1]="trust";    // No password authentication
+    //d.choices[2]="password"; // Password authentication
+    //d.choices[3]="ident";    // Ident (RFC 1413) protocol
     
     return dpi;
   }