DatabaseMetaData

Lists: pgsql-jdbc
From: Glenn Holmer <gholmer(at)weycogroup(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: DatabaseMetaData
Date: 2006-05-22 22:34:06
Message-ID: 200605221734.06987.gholmer@weycogroup.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Can someone give me the right incantation to get the names of the
columns in a table using DatabaseMetaData? I'm trying

dmd = conn.getMetaData();
rs = dmd.getColumns("pg_attribute", "public", "tsoldto", null);
while (rs.next()) {

(where "tsoldto" is the name of my table) and not getting anything in
the result set. What is that last argument supposed to be if I want to
retrieve all the column names, and are the first two correct?

--
____________________________________________________________
Glenn Holmer gholmer(at)weycogroup(dot)com
Software Engineer phone: 414-908-1809
Weyco Group, Inc. fax: 414-908-1601


From: Kris Jurka <books(at)ejurka(dot)com>
To: Glenn Holmer <gholmer(at)weycogroup(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: DatabaseMetaData
Date: 2006-05-22 23:17:14
Message-ID: Pine.BSO.4.63.0605221814510.9728@leary2.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

On Mon, 22 May 2006, Glenn Holmer wrote:

> Can someone give me the right incantation to get the names of the
> columns in a table using DatabaseMetaData? I'm trying
>
> dmd = conn.getMetaData();
> rs = dmd.getColumns("pg_attribute", "public", "tsoldto", null);
>
> (where "tsoldto" is the name of my table) and not getting anything in
> the result set. What is that last argument supposed to be if I want to
> retrieve all the column names, and are the first two correct?
>

The first argument should be your database name, but this is not actually
causing a problem because that parameter is ignored because pg does not
support cross database calls. Other than that it looks good. Are you
sure it's in the public schema? Are you sure it wasn't created with a
case sensitive table name "tSoldTo" or something?

Kris Jurka


From: Glenn Holmer <gholmer(at)weycogroup(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: DatabaseMetaData
Date: 2006-05-23 13:25:09
Message-ID: 200605230825.09655.gholmer@weycogroup.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

On Monday 22 May 2006 18:17, you wrote:
> The first argument should be your database name, but this is not
> actually causing a problem because that parameter is ignored because
> pg does not support cross database calls. Other than that it looks
> good. Are you sure it's in the public schema? Are you sure it
> wasn't created with a case sensitive table name "tSoldTo" or
> something?

Thanks. The DDL to create the table was:

CREATE TABLE tsoldto(
uid_pk INTEGER
...

and I found that while this works:

dmd = conn.getMetaData();
rs = dmd.getColumns("licensee", "public", "tsoldto", "%");
// rs = dmd.getColumns("licensee", "public", "tSoldTo", "%");
while (rs.next()) {
columnNames.add(rs.getString("COLUMN_NAME"));
}
rs.close();

using the commented-out line does not. I thought table names were
case-insensitive? (this is with Postgres 8.0.3 and build 316 of the
JDBC driver).

--
____________________________________________________________
Glenn Holmer gholmer(at)weycogroup(dot)com
Software Engineer phone: 414-908-1809
Weyco Group, Inc. fax: 414-908-1601


From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Glenn Holmer <gholmer(at)weycogroup(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: DatabaseMetaData
Date: 2006-05-23 13:50:17
Message-ID: 44731319.1040805@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Glenn Holmer wrote:

> I thought table names were
> case-insensitive?

They are case sensitive, but forced to lowercase when used unquoted in a
query. See DatabaseMetaData.supportsMixedCaseQuotedIdentifiers() etc.

-O


From: Glenn Holmer <gholmer(at)weycogroup(dot)com>
To: Undisclosed(dot)Recipients: ;
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: DatabaseMetaData
Date: 2006-05-23 18:28:10
Message-ID: 200605231328.10329.gholmer@weycogroup.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

On Tuesday 23 May 2006 08:50, Oliver Jowett wrote:
> Glenn Holmer wrote:
> > I thought table names were
> > case-insensitive?
>
> They are case sensitive, but forced to lowercase when used unquoted
> in a query. See DatabaseMetaData.supportsMixedCaseQuotedIdentifiers()
> etc.

Thanks all, working great now.

--
____________________________________________________________
Glenn Holmer gholmer(at)weycogroup(dot)com
Software Engineer phone: 414-908-1809
Weyco Group, Inc. fax: 414-908-1601