Re: how to Escape single quotes with PreparedStatment

From: Maciek Sakrejda <msakrejda(at)truviso(dot)com>
To: JavaNoobie <vivek(dot)mv(at)enzentech(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: how to Escape single quotes with PreparedStatment
Date: 2011-08-21 01:52:49
Message-ID: CAH_hXRazM9EAOwRT18CW0hvyjoGy2xGbBneNs-PYBG8R_atZHA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

> However , the query fails with postgresql when a double quote is passed into
> it.I was under the impression that Prepared statement would take care of the
> same . But can anyone explain why I'm getting the error?

What do you mean by "passed into it"? There are no parameter markers
in your query. PostgreSQL/JDBC can only handle escaping of parameter
values for you if you provide them as actual parameters, rather
concatenating them into the query string.

---
Maciek Sakrejda | System Architect | Truviso

1065 E. Hillsdale Blvd., Suite 215
Foster City, CA 94404
(650) 242-3500 Main
www.truviso.com

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Radosław Smogura 2011-08-21 10:45:14 Re: how to Escape single quotes with PreparedStatment
Previous Message dmp 2011-08-20 15:10:01 Re: how to Escape single quotes with PreparedStatment