Solved

Using an XML file as a database from a Java application - Possible?

Posted on 2009-03-30
8
433 Views
Last Modified: 2013-11-23
Hi Java experts,

I was wondering if it is possible to interact with an XML file just like you would interact with, say a MySQL database. I've looked at JAXB, JiXB, and a host of other frameworks that let an application transform an XML document into an object tree. The data can then be manipulated and marshaled back into XML.

What I wanted to know is that is it possible for multiple users to be using that application as an interface to interact with the XML file to create, update, or delete "records", while ensuring data integrity, just like you would in a database?

Any comments/advice will be greatly appreciated.
0
Comment
Question by:FaTaFaT
  • 4
  • 4
8 Comments
 
LVL 92

Expert Comment

by:objects
ID: 24024834
0
 

Author Comment

by:FaTaFaT
ID: 24024920
Thank you for your response.

These are wonderful suggestions. However, my situation is that I want a solution where nothing has to be installed. This is because it is a school project and unfortunately the instructor may not want to install these tools at their end when they try to run my code. I'm sorry I didn't mention this in my question.

The project requirement says: develop an application that supports multiple users with varying user privileges, to interact with data in different ways. Typical examples provided by the instructor were: book club application, or a travel agency application.

So, is there any other way, if not through XML, that is not dependent on having certain tools installed to achieve all this in Java?
0
 
LVL 92

Expert Comment

by:objects
ID: 24024994
you'll need to build that sort of functionality yourself. java doesn't come with support for using xml as a multi user database

0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:FaTaFaT
ID: 24025081
I see. So, is there any resource / library / api that I should consider in trying to figure out how that sort of functionality can be built?
0
 
LVL 92

Accepted Solution

by:
objects earned 250 total points
ID: 24025138
you could just use object serialization

0
 

Author Comment

by:FaTaFaT
ID: 24025625
Thank you for pointing me in the right direction. Following your suggestion, I have read quite a few internet resources on object serialization. However, there is still one question that I couldn't find the answer for. What happens when there are multiple sessions? ie, many users de-serializing the same object file at the same time and trying to commit back different updates. Are all the updates serialized back into the object file in a coherent fashion (proper merging, avoiding race conditions, etc.)?
0
 
LVL 92

Expert Comment

by:objects
ID: 24025668
you would manage that from your application, for example using synchronisation

0
 

Author Comment

by:FaTaFaT
ID: 24025689
Alright. I'll look into that too. Thanks for all your comments and suggestions "objects".
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question