Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 438741337C19 for ; Thu, 7 Oct 2010 21:50:07 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 37834-05 for ; Fri, 8 Oct 2010 00:50:01 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from triangle.vision.net (triangle.vision.net [216.129.224.17]) by mail.postgresql.org (Postfix) with ESMTP id 729361337C26 for ; Thu, 7 Oct 2010 21:49:56 -0300 (ADT) Received: from www.webmail.itstriangle.com (localhost [127.0.0.1]) by triangle.vision.net (Postfix) with ESMTP id 5126A450CF for ; Thu, 7 Oct 2010 18:50:19 -0600 (MDT) Received: from 216.220.28.183 (SquirrelMail authenticated user danap) by www.webmail.itstriangle.com with HTTP; Thu, 7 Oct 2010 18:50:19 -0600 Message-ID: <77ea1411cd9895f924e706b418d03702.squirrel@www.webmail.itstriangle.com> Date: Thu, 7 Oct 2010 18:50:19 -0600 Subject: DatabaseMetaData.getTablePrivileges() From: danap@itstriangle.com To: pgsql-jdbc@postgresql.org User-Agent: SquirrelMail/1.4.19 MIME-Version: 1.0 Content-Type: multipart/mixed;boundary="----=_20101007185019_73814" X-Priority: 3 (Normal) Importance: Normal X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.001 tagged_above=-10 required=5 tests=BAYES_20=-0.001 X-Spam-Level: X-Archive-Number: 201010/69 X-Sequence-Number: 21037 ------=_20101007185019_73814 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Today I update the one of the development systems for the MyJSQLView project to test the PostgreSQL 9.0 database. Once the database was installed and also the latest JDBC 9.0-801 I tested the program. The application crashed and after some testing I attributed the exception to the empty string "" parameter for the schemaPattern argument in DatabaseMetaData.getTablePrivileges() for the JDBC. Well not sure the JDBC is really causing the problem, it is throwing the exception, but the error disappears when the same JDBC is used with the PostgreSQL 8.4.4 database. The Java API since I'm pretty sure 1.4 clearly indicates the empty string "" is valid for the schemaPattern parameter. " Parameters: schemaPattern - a schema name pattern; must match the schema name as it is stored in the database; "" retrieves those without a schema; null means that the schema name should not be used to narrow the search " Particulars, Exception, and Abbreviated Code attached. Source for the code, MyJSQLView_Access, http://code.google.com/p/myjsqlview/source/browse/ danap. -------------------------------------------------------- Linux Platform Java(TM) SE Runtime Environment (build 1.6.0_01-b06) postgresql-9.0-801.jdbc3.jar & postgresql-9.0.801.jdbc4.jar SQL version: PostgreSQL 8.4.4 (Works Fine) SQL version: PostgreSQL 9.0.1 (Crashes) Exception in thread "AWT-EventQueue-0" java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(Unknown Source) at org.postgresql.jdbc2.AbstractJdbc2DatabaseMetaData.addACLPrivileges(AbstractJdbc2DatabaseMetaData.java:2799) at org.postgresql.jdbc2.AbstractJdbc2DatabaseMetaData.parseACL(AbstractJdbc2DatabaseMetaData.java:2878) at org.postgresql.jdbc2.AbstractJdbc2DatabaseMetaData.getTablePrivileges(AbstractJdbc2DatabaseMetaData.java:2700) at com.dandymadeproductions.myjsqlview.MyJSQLView_Access.loadDBTables(MyJSQLView_Access.java:1559) at com.dandymadeproductions.myjsqlview.MyJSQLView_Access.accessCheck(MyJSQLView_Access.java:1200) at com.dandymadeproductions.myjsqlview.MyJSQLView_Access.actionPerformed(MyJSQLView_Access.java:628) ---------------------------------------------------------- ------=_20101007185019_73814 Content-Type: text/plain; name="dbTables.txt" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="dbTables.txt" DatabaseMetaData dbMetaData; ResultSet db_resultSet; try { dbMetaData = dbConnection.getMetaData(); db_resultSet = dbMetaData.getTables(catalog, schemaPattern, tableNamePattern, tableTypes); schemas.removeAllElements(); tables.removeAllElements(); while (db_resultSet.next()) { // ************************************************************ // PostgreSQL databases may have schemas that limit access to // tables by users. So make a check and remove tables that are // not accessable by the user. if (subProtocol.equals("postgresql")) { db_resultSet = dbMetaData.getTablePrivileges(db, "", "%"); while (db_resultSet.next()) { String tableName, grantee, user; tableName = db_resultSet.getString("TABLE_NAME"); if (tables.contains(tableName)) { grantee = db_resultSet.getString("GRANTEE"); user = MyJSQLView_Access.getCurrentUser(); if (tables.contains(tableName) && !grantee.equals(user)) tables.remove(tableName); } } } db_resultSet.close(); } catch (SQLException e) { throw e; } ------=_20101007185019_73814--