File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Storing XML in the Database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Storing XML in the Database" Watch "Storing XML in the Database" New topic
Author

Storing XML in the Database

Paul Grew
Greenhorn

Joined: Jul 18, 2011
Posts: 1
I am working on an application that will require storing xml in the database. The xml will contain user permissions that will be loaded into a POJO after the user logs in(Using JAXB). The permissions will be created/edited by the same application. We are using Oracle database. My question is what's the best way of storing XML in the database. Should I use XMLTYPE, or VARCHAR? Is there a better way to accomplish this. Thanks in advance for your advice.

P.S. The reason I am storing permissions in the XML because I want to be albe to add/change permissions without adding more columns to the permissions table.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29233
    
136

Paul,
Welcome to CodeRanch!

An XML type is better than varchar. I don't follow you reason though. I understand not wanting to add columns, but you don't need to. What if you had a table permission_details with columns id, name and value? You'd just add a new row (name/value pair) for a given id and query directly. Managing security in the app is fine too, but you wouldn't need to add a column either way.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Madhan Sundararajan Devaki
Ranch Hand

Joined: Mar 18, 2011
Posts: 312

In fact, designing your tables to withstand/evolve-to future modification will be the most recommended option.



S.D. MADHAN
Not many get the right opportunity !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Storing XML in the Database
 
Similar Threads
J2EE Security
XML parse error
avoid cache in websphere
Stopping unauthorized access of files on the server
Polish characters are gets changed to ? in websphere6.1 environment