db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Knut Anders Hatlen <knut.hat...@oracle.com>
Subject Re: Exception while inserting a record
Date Thu, 13 Sep 2012 10:54:41 GMT
Suat Gonul <suatgonul@gmail.com> writes:

> Hi Knut,
> It seems that is the problem, thanks. But, then I think I should escape
> special characters contained the values. Is there standard procedure for
> this? Is there a list of of special characters? What do you suggest?

I'd suggest that you use prepared statements with parameter markers

INSERT INTO t (id, revision) VALUES (?, 1)

and use ps.setString(1, "string value") to set the value. Then you don't
need to worry about special characters in the string.

If you want to specify the string literally in your SQL statement, only
the single-quote character is a special character, as far as I know, and
it can be escaped with an extra single-quote character. For example, to
insert the string Ā«It's safer with PreparedStatementĀ», you would have to
do something like this:

INSERT INTO t (id, revision) VALUES ('It''s safer with PreparedStatement', 1)

View raw message