From: | "David Johnston" <polobo(at)yahoo(dot)com> |
---|---|
To: | "'Arun Nadar'" <arun_rt(at)rocketmail(dot)com>, <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Problem using PostgreSQL 9.0.4 with Java |
Date: | 2011-09-07 22:02:45 |
Message-ID: | 00e201cc6da9$dfc1ea70$9f45bf50$@yahoo.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
From: pgsql-general-owner(at)postgresql(dot)org
[mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Arun Nadar
Sent: Wednesday, September 07, 2011 4:45 PM
To: pgsql-general(at)postgresql(dot)org
Subject: [GENERAL] 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Chris Redekop | 2011-09-07 22:06:53 | master-side counterpart of pg_last_xact_replay_timestamp? |
Previous Message | John R Pierce | 2011-09-07 21:58:14 | Re: Demoting master to slave without an rsync...is it safe? |