wood burning stoves 2.0*
The moose likes Websphere and the fly likes Comma in db2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "Comma in db2" Watch "Comma in db2" New topic
Author

Comma in db2

shiva shankar
Ranch Hand

Joined: Jun 10, 2001
Posts: 84
Hi all
How to insert comma or single quote in db2..suppose I have d'souza as a column how do i insert into sql query in db2
Thanks in advance
Shiva
Fred Abbot
Ranch Hand

Joined: Jun 01, 2000
Posts: 300
what is a d'souza?
Originally posted by shiva shankar:
Hi all
How to insert comma or single quote in db2..suppose I have d'souza as a column how do i insert into sql query in db2
Thanks in advance
Shiva

shiva shankar
Ranch Hand

Joined: Jun 10, 2001
Posts: 84
d'souza is the coloumn value...sorry for the misinterpretation
Fred Abbot
Ranch Hand

Joined: Jun 01, 2000
Posts: 300
the escape clause is to put another single quote in from of it similar to \\in java ''
shiva shankar
Ranch Hand

Joined: Jun 10, 2001
Posts: 84
This does not work in db2...that's the problem
shiva
Fred Abbot
Ranch Hand

Joined: Jun 01, 2000
Posts: 300
what happens when you try it?
Fred Abbot
Ranch Hand

Joined: Jun 01, 2000
Posts: 300
try this
public String fixquote(String quotedString) {
String tmp = "";
try {
for(int i = 0; i < quotedString.length(); i++)
if(quotedString.substring(i, i + 1).compareTo("\"") == 0)
tmp = tmp + """;
else
tmp = tmp + quotedString.substring(i, i + 1);
}
catch(Error error) { }
return tmp;
}
sudarshan rangarajan
Greenhorn

Joined: Aug 06, 2001
Posts: 1
I suggest you use PreparedStatement to construct the SQL and later on provide the value for the column using setString() method.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Comma in db2
 
Similar Threads
DB2
Apostrophe Abusers Anonymous
InputStream question required
Insert with '
Textarea and csv file