• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

storing xml

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).]
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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.
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java�2 Platform.
 
Frank Carver
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is really more of a database question than one on XML, so I've moved it over. You may want to search the database forum to see if a solution has already been posted, too.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 227
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
USE A PREPARED STATEMENT. Example:

Then the database will deal with the string. The above uses an oracle sequnce, but I'll assume you can conform your code to this...
 
ram my
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks rahul,
Its working!!
 
And will you succeed? Yes you will indeed! (98 and 3/4 % guaranteed) - Seuss. tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic