Received: from mail.gmx.net (pop.gmx.net [194.221.183.20]) by hub.org (8.10.1/8.10.1) with SMTP id e5IGetM44212 for ; Sun, 18 Jun 2000 12:40:55 -0400 (EDT) Message-Id: <200006181640.e5IGetM44212@hub.org> Received: (qmail 13756 invoked by uid 0); 18 Jun 2000 16:40:47 -0000 Received: from line01ed.kdt.de (HELO un69) (195.8.238.237) by mail.gmx.net with SMTP; 18 Jun 2000 16:40:47 -0000 From: "=?iso-8859-1?q?Christian_Pr=F6hl?=" To: "pgsql-interfaces" Date: Sun, 18 Jun 2000 18:40:30 +0200 (CEST) Reply-To: "=?iso-8859-1?q?Christian_Pr=F6hl?=" X-Mailer: PMMail 2.10.2010 for OS/2 Warp 4.00 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Subject: JDBC 7.0 driver: Metadata support X-Archive-Number: 200006/91 Hello, I'm just exploring the metadata support of postgreSQL 7.0's JDBC-driver. So I found a bug concerning table meta datas: In jdbcX\DatabaseMetadaData.java following methods should be fixed in the following way (tested on OS/2 with JDK 1.1.7 and PostgreSQL 7.0). Then you can query what a table has. Code changes are commented with [CP]. ----------------------------)schnipp(------------------------------------- public java.sql.ResultSet getTableTypes() throws SQLException { Field f[] = new Field[1]; Vector v = new Vector(); byte[][] tuple = new byte[1][0]; f[0] = new Field(connection,new String("TABLE_TYPE"),iVarcharOid,32); for(int i=0;i // Now take the pattern into account sql.append(") and relname like '"); sql.append(tableNamePattern.toLowerCase()); sql.append("'"); // Now run the query r = connection.ExecSQL(sql.toString()); byte remarks[]; while (r.next()) { byte[][] tuple = new byte[5][0]; // Fetch the description for the table (if any) java.sql.ResultSet dr = connection.ExecSQL( "select description from pg_description where objoid="+r.getInt(2)); if(((org.postgresql.ResultSet)dr).getTupleCount()==1) { dr.next(); remarks = dr.getBytes(1); } else remarks = defaultRemarks; dr.close(); tuple[0] = null; // Catalog name tuple[1] = null; // Schema name tuple[2] = r.getBytes(1); // Table name tuple[3] = null; // Table type tuple[3] = r.getBytes(3); /* [CP] return table type as string */ tuple[3] = queryTableType(r.getInt(2),types); tuple[4] = remarks; // Remarks v.addElement(tuple); } r.close(); return new ResultSet(connection, f, v, "OK", 1); } // Additional method to query table type for given // PostgreSQL object. Used by getTables(...) for // TABLE_TYPE // Method added by Christian Pr\u00F6hl private byte[] queryTableType(int oid, String[] types) throws SQLException { if ((types==null)||(types.length==0)) return null; String[][] tableTypes = (getTableTypes); for (int i=0; i