Without more specific information about your needs, my first thought is the H2 Database Engine project. H2 is a pure-Java, open-source, free-of-cost, relational database that has been actively developed for years.
The "2" refers to the fact that this is the second such database (Hypersonic SQL, later forked as HSQLDB) built by its main author, Thomas Mueller, so he knows his stuff.
While H2 can be run as a server, it is especially adept at being embedded inside an app and can run with relatively little memory if need be.
Being pure Java, H2 is built specifically for JDBC access. Comes bundled with its own JDBC driver.
The main web site has good documentation including a QuickStart overview and a Tutorial.
You will need to learn the basics of tables, columns, data types, and SQL commands. You can teach yourself. Getting some tutoring from someone familiar with relational databases will dramatically reduce that learning curve.
H2 is similar to SQLite but more fully featured. Being pure Java and embeddable makes H2 a better fit for your needs and probably easier to get you started.
Over at the sister site, Stack Overflow, I have written a few Answers providing source code for a complete Java example app using H2. Like this, this, this, this, this, and more.
The Apache Derby project is quite similar to H2. Formerly known as IBM Cloudscape, and also known as "Java DB" when provided by Oracle in a bundle with the Java SDK.
Derby is more complicated than H2, including being aimed at use as a server. I suspect H2 is a better fit for your needs.
If all you need is relatively simple data in amounts small enough to be held in memory, then skip the database. Store your data as text in plain files.
Common formats for such plain text files include:
- CSV, Comma-Separated Values.
- TSV. Delimited by Tab.
- ASCII Separators, ASCII codes # 28-31.
Marks file, group, record, and unit/field). Less common that Tab but more sensible and flexible)
Note that while CSV sounds simple, various programmers have found ways to mix things up with variations. For decades, no one even bothered to write down a spec until RFC 4180 in 2005.
When you need this data, read it into memory, instantiate objects by defining your own classes such as "Person" or "Invoice", collect those objects, and search those collections to find desired objects.
While conceptually simple, there are many possible snafus. One of the main purposes of a database engine is to handle such problems for you.
- You need to be sure to close files after using them, although when quitting or crashing the JVM should automatically close any open files.
- You might consider file corruption. What if the app crashes or is otherwise interrupted in the middle of writing a file? One way to handle this is to write a new file and only delete the old one after.
- If you are multi-threaded, then you need to guard against concurrency issues. You don't want different threads trying to replace data for the same file at the same time.
Apache Common CSV
The Apache Commons CSV project is a relatively new pure-Java free-of-cost library to handle the chore of reading and writing plain text files. It handles all the mentioned formats, not just CSV (despite its name). I've used version 1.1 and found it quite useful, robust, and reliable.