pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Nedrow <dnedrow@mac.com>
To: pgsql-jdbc@postgresql.org
Subject: String escaping?
Date: Wed, 13 Dec 2006 12:09:33 -0500
Message-ID: <50899926-5B68-42EC-B126-75EBC7E38BF4@mac.com> (raw)

Are there any build-in JDK or JDBC (Sun or Postgresql driver)  
functions for escaping strings before inserting/updating in the DB?

Eg., I'm using the following PreparedStatement...

addNickname = con.prepareStatement("insert into infobot.nicknames  
(nickname, firstseen) values (?, to_timestamp(?))");

When providing the value via addNickname.setString(1, this.getString 
()), is there some way for me to be sure that the contents of the  
string I'm feeding to setString() are properly formed/escaped.

I'm basically looking for the Java equivalent of PHP's  
pg_escape_string() function...

http://www.php.net/manual/en/function.pg-escape-string.php

I was hoping to avoid writing my own escape method, but may have to  
as I have yet to find anything "off the shelf".

Any suggestions would be appreciated,

-David




view thread (6+ messages)  latest in thread

Message-ID: <50899926-5B68-42EC-B126-75EBC7E38BF4@mac.com>
Permalink:  ../50899926-5B68-42EC-B126-75EBC7E38BF4@mac.com/
Also on:    postgresql.org/message-id/50899926-5B68-42EC-B126-75EBC7E38BF4@mac.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: dnedrow@mac.com
  Subject: Re: String escaping?
  In-Reply-To: <50899926-5B68-42EC-B126-75EBC7E38BF4@mac.com>
  References: <50899926-5B68-42EC-B126-75EBC7E38BF4@mac.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox