Re: Column names getting lower-case in SELECT statements when issued via JDBC

From: Szymon Guz <mabewlun(at)gmail(dot)com>
To: "Eduardas F(dot)" <tcpa252(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Column names getting lower-case in SELECT statements when issued via JDBC
Date: 2011-05-15 19:26:14
Message-ID: BANLkTi=_s4+iL8mbzmWO_2KKXNprJJvNng@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 15 May 2011 21:04, Eduardas F. <tcpa252(at)gmail(dot)com> wrote:

> Hello everyone, today I encountered this nasty problem:
> Whenever you issue an SELECT command from JDBC (prepared statement) you end
> up with column X does not exist. And column X name is shown in lower-case
> As I understand, PostgreSQL Server or PostgreSQL JDBC driver converts column
> names containing upper-case letters to lower-case? Is there an easy way to
> bypass this behaviour? (Channing column names is not an option).
>
>
> Here's an example of crashing SELECT: "SELECT password, accessLevel,
> lastServer, userIP FROM accounts WHERE login=?"
> You end up with 'column "accesslevel" does not exist'.
>
> Thanks for help in advance.
>

Hi,
if you create a column using "accessLevel", then you have to access it using
"accessLevel". If you omit all the quotation marks, then the name is stored
as lowercase so you can access it using accessLevel or ACCESSLEVEL or
accesslevel.

Let's try this query:
"SELECT \"password\", \"accessLevel\", \"lastServer\", \"userIP\" FROM
accounts WHERE login=?"

I don't think there is any way to change the default behavior.

regards
Szymon

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bernardo Telles 2011-05-16 03:53:30 How do we combine and return results from multiple queries in a loop?
Previous Message Jerry Sievers 2011-05-15 19:26:08 Re: Column names getting lower-case in SELECT statements when issued via JDBC