Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 0003D358181 for ; Fri, 9 Dec 2011 13:54:41 -0400 (AST) Received: from [216.146.104.103] (helo=outbound.vnet-inc.com) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RZ4ee-0007RJ-03 for pgsql-jdbc@postgresql.org; Fri, 09 Dec 2011 17:54:41 +0000 Received: from [192.168.157.132] (unknown [76.75.27.41]) by outbound.vnet-inc.com (Postfix) with ESMTP id 727A3592F; Fri, 9 Dec 2011 10:54:06 -0700 (MST) Message-ID: <4EE249EA.40807@ttc-cmc.net> Date: Fri, 09 Dec 2011 10:48:26 -0700 From: dmp User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.13) Gecko/20100914 SeaMonkey/2.0.8 MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org, the6campbells@gmail.com Subject: Re: getTables not returning 10 columns etc Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 216.146.104.103 (deferred) X-Pg-Spam-Score: -1.1 (-) X-Archive-Number: 201112/50 X-Sequence-Number: 22504 > re documentation > http://docs.oracle.com/javase/6/docs/api/java/sql/ResultSetMetaData.html > > re example > > Server: 9.0.4 Driver: PostgreSQL Native Driver: PostgreSQL 9.1 JDBC3 > (build 901) > > ResultSet rs = meta.getTables(null, null, null, null); > ResultSetMetaData rsmd = rs.getMetaData(); > System.out.println(rsmd.getColumnCount()); > > This will print the value of 5 not 10. > > Change the code to > for (int i = 1; i <= rsmd.getColumnCount(); i++) { > System.out.println(rsmd.getColumnName(i)); > } > > http://docs.oracle.com/javase/6/docs/api/java/sql/DatabaseMetaData.html#getTables(java.lang.String, > java.lang.String, java.lang.String, java.lang.String[]) > returns names as follows was expecting upper case names similar to > rs.getString("TABLE_NAME") > table_cat > table_schem > table_name > table_type > remarks The second reference you give to the DatabaseMetaData indicates in the javadocs information for the getTables(): "Note: Some databases may not return information for all tables." Indeed the PostgreSQL JDBC does only return the first five as does MySQL, but SQLite gives all ten. As far as the column names as others have said one should not rely on any particular case defaults. I learned with the MyJSQLView application to always stipulate names with the database identifer to fully qualifier table and column names. Example: -- MyJSQLView SQL Dump -- Version: 3.31 -- WebSite: http://myjsqlview.org -- -- Host: 127.0.0.1 -- Generated On: 2011.12.09 AD at 09:30:36 MST -- SQL version: PostgreSQL 9.0.1 -- Database: key_tables -- -- -- Table structure for table "public"."keY_tAble2" -- DROP TABLE IF EXISTS "public"."keY_tAble2"; CREATE TABLE "public"."keY_tAble2" ( "Host" char(60) DEFAULT '' NOT NULL, "Db" char(64) DEFAULT '' NOT NULL, "Username" char(16) DEFAULT '' NOT NULL, "select_priv" boolean DEFAULT true NOT NULL, PRIMARY KEY ("Host","Db","Username") ); -- -- Dumping data for table "public"."keY_tAble2" -- INSERT INTO "public"."keY_tAble2" ("Host", "Db", "Username", "select_priv") VALUES('cindy', 'sample', 'danap', 't'); Output from getTables(); Table CAT: null Table Schem: public Table Name: keY_tAble2 Table Type: TABLE Remarks: null