Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Databases > How to insert a...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 3640 of 3876
Post > Topic >>

How to insert a string that contains ' or ,

by macit <ilona.ersek@[EMAIL PROTECTED] > Feb 5, 2008 at 01:32 PM

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.
 




 4 Posts in Topic:
How to insert a string that contains ' or ,
macit <ilona.ersek@[EM  2008-02-05 13:32:14 
Re: How to insert a string that contains ' or ,
Donkey Hot <spam@[EMAI  2008-02-05 21:28:36 
Re: How to insert a string that contains ' or ,
=?ISO-8859-1?Q?Arne_Vajh=  2008-02-05 22:17:00 
Re: How to insert a string that contains ' or ,
macit <ilona.ersek@[EM  2008-02-05 13:56:54 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Dec 3 23:31:55 CST 2008.