X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 163EE8B9C8C for ; Tue, 22 Feb 2005 17:29:06 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 39391-06 for ; Tue, 22 Feb 2005 17:28:56 +0000 (GMT) Received: from koolancexeon.g2switchworks.com (mail.g2switchworks.com [63.87.162.25]) by svr1.postgresql.org (Postfix) with ESMTP id F1EC88B9B5D for ; Tue, 22 Feb 2005 17:28:55 +0000 (GMT) Received: mail.g2switchworks.com 10.10.1.8 from 10.10.1.37 10.10.1.37 via HTTP with MS-WebStorage 6.5.6944 Received: from state.g2switchworks.com by mail.g2switchworks.com; 22 Feb 2005 11:28:54 -0600 Subject: Re: From: Scott Marlowe To: Brian Gunning Cc: pgsql-jdbc@postgresql.org In-Reply-To: References: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Message-Id: <1109093334.30529.114.camel@state.g2switchworks.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Tue, 22 Feb 2005 11:28:54 -0600 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200502/157 X-Sequence-Number: 12337 On Tue, 2005-02-22 at 11:15, Brian Gunning wrote: > Hi, >=20 > =20 >=20 > I am currently migrating my database from MS Access to postgreSQL or > MySQL. I am accessingthe databse using a program written in Java. I > have all necessary drivers installed/initialised etc. My server > program starts and connects to the database fine. The problem occurs > when I start my client program, which runs a SQL command to read the > database and populate a JTree. When I migrated to MySQL no changes to > my code/SQL commands were necessary but when the client starts using > postgreSQL it errors out at the line accessing the DB with the > following error=E2=80=A6 >=20 > =20 >=20 > java.sql.SQLException: ERROR: column "groupid" does not exist =E2=80=A6 >=20 > =20 >=20 > The column does exist but the actual name of the column is =E2=80=98group= ID=E2=80=99 > (with last two chars. in upper case) and it is of type int4. Are there > any case-sensitive issues I should take into account here? >=20 > =20 >=20 > This line ( and all SQL commands) cause no problems when using MS > Access and MySQL. The database was created by exporting the database > from MS Access. Both MySQL and PostgreSQL are behaving against the spec, with a slight difference. MySQL is NOT folding case (but it should be) to upper, but is keeping the case that comes in on the query, unquoted: select groupID from table=20 SHOULD become, according to the spec: select GROUPID from TABLE. PostgreSQL is behaving against spec by folding case (as it should) to lower (as the spec says it shouldn't) So, for postgresql, the query above becomes select groupid form table. Quoted identifiers, are not case folded (per spec): select "groupID" from table becomes (in SQL land) select groupID from TABLE (but in postgresql it becomes select groupID from table. While both databases are "getting it wrong" the easy fix would be to just quote everything. However, MySQL quotes with back ticks, so you'd need to quote that way for MySQL (unless they allow " quotes nowadays, I don't know, I don't use it much anymore) select `groupID` from table for MySQL and select "groupID" from table for PostgreSQL. Note that consistent quoting gets rid of this problem. I.e. either always quote everything, or never quote anything.