Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8351593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:40:47+00:00 2026-06-09T08:40:47+00:00

I am writing a program in Java which tracks data about baseball cards. I

  • 0

I am writing a program in Java which tracks data about baseball cards. I am trying to decide how to store the data persistently. I have been leaning towards storing the data in an XML file, but I am unfamiliar with XML APIs. (I have read some online tutorials and started experimenting with the classes in the javax.xml hierarchy.)

The software has to major use cases: the user will be able to add cards and search for cards.

When the user adds a card, I would like to immediately commit the data to the persistant storage. Does the standard API allow me to insert data in a random-access way (or even appending might be okay).

When the user searches for cards (for example, by a player’s name), I would like to load a list from the storage without necessarily loading the whole file.

My biggest concern is that I need to store data for a large number of unique cards (in the neighborhood of thousands, possibly more). I don’t want to store a list of all the cards in memory while the program is open. I haven’t run any tests, but I believe that I could easily hit memory constraints.

XML might not be the best solution. However, I want to make it as simple as possible to install, so I am trying to avoid a full-blown database with JDBC or any third-party libraries.

So I guess I’m asking if I’m heading in the right direction and if so, where can I look to learn more about using XML in the way I want. If not, does anyone have suggestions about what other types of storage I could use to accomplish this task?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T08:40:48+00:00Added an answer on June 9, 2026 at 8:40 am

    While I would certainly not discourage the use of XML, it does have some draw backs in your context.

    “Does the standard API allow me to insert data in a random-access way”

    Yes, in memory. You will have to save the entire model back to file though.

    “When the user searches for cards (for example, by a player’s name), I would like to load a list from the storage without necessarily loading the whole file”

    Unless you’re expected multiple users to be reading/writing the file, I’d probably pull the entire file/model into memory at load and keep it there until you want to save (doing periodical writes the background is still a good idea)

    I don’t want to store a list of all the cards in memory while the program is open. I haven’t run any tests, but I believe that I could easily hit memory constraints

    That would be my concern to. However, you could use a SAX parser to read the file into a custom model. This would reduce the memory overhead (as DOM parsers can be a little greedy with memory)

    “However, I want to make it as simple as possible to install, so I am trying to avoid a full-blown database with JDBC”

    I’d do some more research in this area. I (personally) use H2 and HSQLDB a lot for storage of large amount of data. These are small, personal database systems that don’t require any additional installation (a Jar file linked to the program) or special server/services.

    They make it really easy to build complex searches across the datastore that you would otherwise need to create yourself.

    If you were to use XML, I would probably do one of three things

    1 – If you’re going to maintain the XML document in memory, I’d get familiar with XPath
    (simple tutorial & Java’s API) for searching.

    2 – I’d create a “model” of the data using Objects to represent the various nodes, reading it in using a SAX. Writing may be a little more tricky.

    3 – Use a simple SQL DB (and Object model) – it will simply the overall process (IMHO)

    Additional

    As if I hadn’t dumped enough on you 😉

    If you really want to XML (and again, I wouldn’t discourage you from it), you might consider having a look a XML database style solution

    Apache Xindice (apparently retired)

    Or you could have a look at some other people think

    • Use XML as database in Java
    • Java: XML into a Database, whats the simplest way?

    For example 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a Java program where I have to extract some data from a
At work training, I'm writing a Java (in which I have 0 experience) program
I am writing a java program in which I have to write all integers
I'm writing this Java program in which I have a JFrame and a Thread.
I am writing a Java program which automatically plugs information into a website, which
I m writing a program which involves converting java.util.Date to java.sql.Date... I've done it
I'm writing a program in Java where I read in data from an XML
I'm writing a program in Java and I have a method with a header
I'm currently writing a java program that requires some Data to run. The data
I'm writing a simple program in Java which includes a KeyListener with the following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.