JDBC - escaping quotes?

From: lloyd <subscr001(at)twilight-systems(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: JDBC - escaping quotes?
Date: 2002-05-07 21:21:10
Message-ID: 1020806474.4189.16.camel@twilight
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Using a PreparedStatement under pgjdbc2.jar, shouldn't the driver escape
quotes in Strings?

If I try something like this:

String sql = "insert into book_list (name) values ? ";
PreparedStatement stmt = cn.prepareStatement(sql);

String name = "\"Media Unlimited\", by Todd Gitlin";
stmt.setString(1, name);
stmt.addBatch();
stmt.execute();

I would expect a row in the db with a name column of:

"Media Unlimited", by Todd Gitlin

Instead, though the row is added, the column is blank.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Randall Perry 2002-05-07 21:34:27 Can this be done in one query?
Previous Message Booth, Robert 2002-05-07 20:56:28 NOT IN query issues