how do i store an xml string in a database the " and ' chars do not allowing me to store the xml string i've tried vaarchar2,clob,long raw none work any suggestions will be welcome!!! ------------------ josh [This message has been edited by joshua k (edited February 01, 2001).]
"joshua k", The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please choose a new name which meets the requirements. Thanks.
I am not an expert of the field. However, I faced the same situation and had to write an encoding function myself. It replaced all single or double quotation marks in a string with my own strings. I mean you need a custom designed solution made by yourself. There is no other way out. Just my opinion. Muhammad Ali Shah Karachi.
Here are some suggestions - a) Since ALL attribute values needs to be quoted, you can simply omit the quote while storing and put the quote while restoring. b) Use some kind of a unique pattern( eg - #*quote*# ) while storing and replace it with the actual quote while retreiving.
hi In my application using dom Object i write an flat xml File, i want to put xml contents inside the database 1) can i store the xmlcontents directly into databse with out writing in the Flat File 2)can i store the file as String inside the dataBase instead of CLOB which is Better? 3)As Benoit said, can i go for JDBC 3.0 which Explictly supportts all database without using SPecific Interface(ex:java.sql.CLOB) 4)is there anyway i can i store the File which should Explictly support all databases. Its Urgent ,plz Reply Soon.... Thanks Ramesh Krishnan
I have once written some sample code for this. I was using LONG datatype of oracle to stored the XML Document. From Java World I was using setAsciiStream() method to send the XML Data I am not sure dont know if thats the best way round. But it works.
If you go with a varchar datatype where double quotes are acceptable and only single quotes give you a problem, then the trick is to parse it and replace all single quotes with two single quotes. Works for db2. See your database documentation - there is always some way to get quotes stored in there, its just a matter of finding the way your database allows it. I've also found that in using prepared statements, I don't have to deal with this issue anymore - it just handles it the right way. So you may want to give that a try.