Skip site navigation (1) Skip section navigation (2)

Re: BUG: DatabaseMetaData.getColumns isn't case insensitive

From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: maly(dot)velky(at)email(dot)cz
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: BUG: DatabaseMetaData.getColumns isn't case insensitive
Date: 2009-02-02 21:32:13
Message-ID: 491f66a50902021332w66598e8fhe6a2ed5b3a3ad8d1@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-jdbc
Shouldn't you quote the column in question if you want to get a MixedCase
quoted column ?

Dave

On Mon, Feb 2, 2009 at 8:39 AM, <maly(dot)velky(at)email(dot)cz> wrote:

> Hello,
>
> I'was trying to get meta data of a column and discovered that the column
> name is case sensitive though it should be case insensitive. I don't know if
> this can be somehow determined by a configuration or environment change
> because I believe that till recently it  worked in a case-insensitive
> manner.
>
> I've the table studna_monitor.mon_user_session with the column "username".
> The following code wrongly returns null (notice "username".toUpperCase()):
> ---
> String col = null;
> Class.forName("org.postgresql.Driver");
> String url = "jdbc:postgresql://localhost/mydb?user=me&password=secret";
> Connection conn = DriverManager.getConnection(url);
>        DatabaseMetaData databaseMetaData = conn.getMetaData();
>        ResultSet columnsMD = databaseMetaData.getColumns(null,
> "studna_monitor", "mon_user_session", "username".toUpperCase());
>        while(columnsMD.next()) {
>                col = columnsMD.getString("COLUMN_NAME");
>        }
>        return col;
> ---
> While the following returns the column name "username":
> ---
> ...
> ResultSet columnsMD = databaseMetaData.getColumns(null, "studna_monitor",
> "mon_user_session", "username".toLowerCase());
> ...
> ---
>
> BTW, the metadata reports:
> supportsMixedCaseIdentifiers: false
> supportsMixedCaseQuotedIdentifiers: true
> (which is pretty much expected)
>
> Driver: postgresql-8.3-604.jdbc3.jar, postgresql-jdbc3-8.2.jar (as
> distributed with Ubuntu, doesn't provide build number)
> Server:  Postgres 8.2.6 for Solaris
>
>
> Thank you.
> Jakub Holy
> maly(dot)velky(at)email(dot)cz
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc
>

In response to

pgsql-jdbc by date

Next:From: David SunDate: 2009-02-03 04:21:45
Subject: documentation error
Previous:From: maly.velkyDate: 2009-02-02 13:39:59
Subject: BUG: DatabaseMetaData.getColumns isn't case insensitive

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group