Search Postgresql Archives

Re: Problem using PostgreSQL 9.0.4 with Java

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: pgsql-general-owner@xxxxxxxxxxxxxx [mailto:pgsql-general-owner@xxxxxxxxxxxxxx] On Behalf Of Arun Nadar
Sent: Wednesday, September 07, 2011 4:45 PM
To: pgsql-general@xxxxxxxxxxxxxx
Subject: Problem using PostgreSQL 9.0.4 with Java

 

Hi

 

but it work by putting " ",  like this SELECT "Id", "Name" FROM "Student" ORDER BY "Id";

 

in java String,  inside of double inverted commas another is does not possible.

 

how this code is implement through java program. please kindly send me the solution for this.

 

 

To include the “quote” symbol in a Java string you need to escape it with the “back-slash” symbol (i.e.,  “\” ) as so:

 

String var = “SELECT \”Id\” FROM \”Table\””;

 

The reason you are having to do this is you defined your table and column names in a case-sensitive manner BUT PostgreSQL automatically converts to lowercase any identifier that is not enclosed in quotes.

 

I would suggest you do some more reading on how Strings in Java work since if you missed how to include the common quote in a String literal you likely missed some other important rules/behavior as well.

 

On the PostgreSQL side I do not know how you created your table(s) but unless you have some overriding reason to avoid doing so you should stick to lower-case; it will make using those tables from within Java much easier (during your hard-coded queries phase of development).  You can still use mixed-case in Java (without the quotes) and then let PostgreSQL convert it into lower-case for you.

 

David J.

 

 

 

 

 


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux