Re: A bug fix for JDBC's getTables() in Postgresql 7.1 - Mailing list pgsql-jdbc
From | Bruce Momjian |
---|---|
Subject | Re: A bug fix for JDBC's getTables() in Postgresql 7.1 |
Date | |
Msg-id | 200105161641.f4GGfb414713@candle.pha.pa.us Whole thread Raw |
In response to | A bug fix for JDBC's getTables() in Postgresql 7.1 (Panu Outinen <panu@vertex.fi>) |
List | pgsql-jdbc |
Thanks. Patch applied to jdbc1 and jdbc2, and attached. I had already patched the ORDER BY as: sql.append("' order by relkind, relname"); > Hi !! > > I was trying to get a very nice FREE graphical db tool called DbVisualizer > (http://www.ideit.com/products/dbvis/) to work with Postgresql and I found > out the following bug: if database has views then getTables() gets the null > pointer exception ('order by relname' makes the listing tree in > DbVisualizer a lot useful !!) > > This patch should propably be applied to the the jdbc1's > DatabaseMetaData.java, too. > > [/tmp/postgresql-7.1/src/interfaces/jdbc/org/postgresql/jdbc2]$ > <ql/jdbc2]$ diff -u DatabaseMetaData.java.org DatabaseMetaData.java > > --- DatabaseMetaData.java.org Wed May 02 22:52:25 2001 > +++ DatabaseMetaData.java Wed May 02 23:07:19 2001 > @@ -1666,7 +1666,7 @@ > // Now take the pattern into account > sql.append(") and relname like '"); > sql.append(tableNamePattern.toLowerCase()); > - sql.append("'"); > + sql.append("' order by relname"); > > // Now run the query > r = connection.ExecSQL(sql.toString()); > @@ -1697,6 +1697,9 @@ > case 'S': > relKind = "SEQUENCE"; > break; > + case 'v': > + relKind = "VIEW"; > + break; > default: > relKind = null; > } > @@ -1704,7 +1707,7 @@ > tuple[0] = null; // Catalog name > tuple[1] = null; // Schema name > tuple[2] = r.getBytes(1); // Table name > - tuple[3] = relKind.getBytes(); // Table type > + tuple[3] = (relKind==null) ? null : relKind.getBytes(); // Table type > tuple[4] = remarks; // Remarks > v.addElement(tuple); > } > > > ----- > http://www.ideit.com/products/dbvis/ > > ... > > DbVisualizer > Version: 2.0 > Released: 2001-04-20 > > > The #1 requested feature to ease editing table data is now supported! > The #2 requested feature to print graphs is now supported! > Read the complete change log for all new features and enhancements! > > > DbVisualizer is a cross platform database visualization and edit tool > relying 100% on the JDBC, Java Database Connectivity API's. DbVisualizer > enables simultaneous connections to many different databases through JDBC > drivers available from a variety of vendors. Just point and click to browse > the structure of the database, characteristics of tables, etc. No matter if > it's an enterprise database from Oracle or an open source product like > InstantDB! > > And best of all -> it's FREE! > ----- > > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026 Index: src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java,v retrieving revision 1.14 diff -c -r1.14 DatabaseMetaData.java *** src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java 2001/05/16 04:08:49 1.14 --- src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java 2001/05/16 16:36:21 *************** *** 1697,1702 **** --- 1697,1705 ---- case 'S': relKind = "SEQUENCE"; break; + case 'v': + relKind = "VIEW"; + break; default: relKind = null; } *************** *** 1704,1710 **** tuple[0] = null; // Catalog name tuple[1] = null; // Schema name tuple[2] = r.getBytes(1); // Table name ! tuple[3] = relKind.getBytes(); // Table type tuple[4] = remarks; // Remarks v.addElement(tuple); } --- 1707,1713 ---- tuple[0] = null; // Catalog name tuple[1] = null; // Schema name tuple[2] = r.getBytes(1); // Table name ! tuple[3] = (relKind==null) ? null : relKind.getBytes(); // Table type tuple[4] = remarks; // Remarks v.addElement(tuple); } Index: src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java =================================================================== RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java,v retrieving revision 1.18 diff -c -r1.18 DatabaseMetaData.java *** src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java 2001/05/16 04:08:50 1.18 --- src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java 2001/05/16 16:36:25 *************** *** 1697,1702 **** --- 1697,1705 ---- case 'S': relKind = "SEQUENCE"; break; + case 'v': + relKind = "VIEW"; + break; default: relKind = null; } *************** *** 1704,1710 **** tuple[0] = null; // Catalog name tuple[1] = null; // Schema name tuple[2] = r.getBytes(1); // Table name ! tuple[3] = relKind.getBytes(); // Table type tuple[4] = remarks; // Remarks v.addElement(tuple); } --- 1707,1713 ---- tuple[0] = null; // Catalog name tuple[1] = null; // Schema name tuple[2] = r.getBytes(1); // Table name ! tuple[3] = (relKind==null) ? null : relKind.getBytes(); // Table type tuple[4] = remarks; // Remarks v.addElement(tuple); }
pgsql-jdbc by date: