How to insert a string that contains ' or ,
- From: macit <ilona.ersek@xxxxxxxxx>
- Date: Tue, 5 Feb 2008 13:32:14 -0800 (PST)
Hello,
i am using the following statement to insert a message from a user
into the database.
updStmt.executeUpdate("INSERT INTO Contact (uId, replyAddr, subject,
msg) "+
"VALUES (" + userId + "," +
"\'" + replyAddr + "\'," +
"\'" + subject + "\'," +
"\'" + msg + "\')");
The variables userId, replyAddr, subject und msg are of type String.
Now if one of the Strings contain a ' or a , character, the sql
statement gets messed up and causes a SqlException. Is there a way
(How) can i store a string that contains ' or , in the database?
Thanks in advance for your assistance.
.
- Follow-Ups:
- Re: How to insert a string that contains ' or ,
- From: Donkey Hot
- Re: How to insert a string that contains ' or ,
- Prev by Date: Re: How to insert a string that contains ' or ,
- Next by Date: Re: How to insert a string that contains ' or ,
- Previous by thread: Re: ResultSet getDate(TIME_STAMP) returns java.lang.NumberFormatException: For input string:
- Next by thread: Re: How to insert a string that contains ' or ,
- Index(es):
Relevant Pages
|
|