Why is columnNames in Connection.prepareStatement(sql, columnNames[]) automatically quoted - Mailing list pgsql-jdbc

From Balázs Zsoldos
Subject Why is columnNames in Connection.prepareStatement(sql, columnNames[]) automatically quoted
Date
Msg-id CAHEBw=S+ON9b+x0X0yavXC3S2Q0sz1GCL7HBp0BZSFQPdzH-_A@mail.gmail.com
Whole thread Raw
Responses Re: Why is columnNames in Connection.prepareStatement(sql, columnNames[]) automatically quoted  (Dave Cramer <pg@fastcrypt.com>)
Re: Why is columnNames in Connection.prepareStatement(sql, columnNames[]) automatically quoted  (Mark Rotteveel <mark@lawinegevaar.nl>)
List pgsql-jdbc
Hi,

I would like to write database independent SQL statements. Everything works well, until I call Connection.prepareStatement(sql, columnNames[]).

In the SQL statement nothing is quoted and it works well. I am wondering, why the values in the columnNames are automatically quoted? Is it a bug or a feature?

More info:

I create the fields and tables in DDL without quoting them. Table and field names become upper or lower case based on the engine. E.g.: In case of Oracle, they will have upper-case names, in PostgreSQL they will have lower-case names.

If I use Oracle, I must provide the columnNames parameter for the mentioned function with upper-case letters otherwise it does not work (I think that is a bug, too, but I guess it is harder to send a patch for Oracle than PostgreSQL :-) ). If I use any other database engines (Derby, SQLServer, Hsqldb) everything works well.

If I use PostgreSQL, however, I must provide lower-case letters for the parameter as it is quoted inside. I do not think it should be quoted. If someone wants to quote those column names, it would be possible by providing the Strings with quotes like Connection.prepareStatement(sql, "\"myCamelCaseColumnName\"");

Do you think there is any chance to change this in PostgreSQL JDBC driver or shall I write separate code for Postgres?

Regards,
Balázs Zsoldos

pgsql-jdbc by date:

Previous
From: Thomas Kellerer
Date:
Subject: Re: need advice about out parameter settings while calling stored procedure in Java code
Next
From: Dave Cramer
Date:
Subject: Re: Why is columnNames in Connection.prepareStatement(sql, columnNames[]) automatically quoted