5

I'm building an application thats going to store artist info, music and other stuff. I was going to use XML as a type of database, but when I was reading some posts on this site, some people said to use a java database. Now I didnt know that they existed for standalone apps. So I came across SQL lite and objectdb.

Am I correct to assume that if I was to use either of these, that the user would have to install separate software? Or will the database software get integrated/compiled/bundled/packaged with my application? I was reading about objectdb and it looks like its something that will get packaged with my application, but not sure.

desertnaut
60.8k32 gold badges155 silver badges183 bronze badges
asked Apr 10, 2011 at 8:18
2
  • 1
    SQLite can be, and is indeed designed to be embedded into applications. Commented Apr 10, 2011 at 8:27
  • Interesting, I guess I will look into SQL Lite. Because after further reading into this, I found out that SQLLite is used in iOS and Android, which is where I would like to start programming after I understand more about Java desktop applications. Commented Apr 10, 2011 at 8:34

4 Answers 4

3

SQLite is a great choice for exactly what you're referring to - a standalone desktop application. It's overhead is minimal, it does not require a running DBMS and therefore does not introduce a dependency at installation time. In actual fact it's incredibly lightweight, all tables are stored within a single .db file. This obviously introduces potential problems with scalability for your application I can't see this becoming a problem.

To get started you will need a driver/wrapper for the SQLite API (it's a C API so a wrapper will prevent you form having to write JNI code!). SQLiteJDBC is one such wrapper...

You might also want to get familiar with the SQLite runtime. It provides a console application to manage tables/schemas. Here's a good starting tutorial...

answered Apr 10, 2011 at 8:38
Sign up to request clarification or add additional context in comments.

Comments

2

Don't use XML for storing your database, unless it will fit completely into the heap memory. XML is designed for exchanging data, not for storing it. For example, you cannot say "get me track 7 of that album" without loading the complete XML file. Typical databases can do that.

answered Apr 10, 2011 at 8:29

1 Comment

Right, whcih is what I found out. However what do you know about using SQLLite, ObjectDB (or any other database) with java? How does the database system get packaged or put together, so that when I distribute my application the user doesn't ahve to install seperate software. I jsut want a better understanding how this works and how it will fit with my application project.
2

H2 Database Engine

Maybe you should have a look at the H2 Database Engine. It is very easy to embed into Java because it’s only a small (~ 1MB) jar-File. I did not used it by myself but recommended it to many friends and they all gave me a good feedback.

Here you can find a nice tutorial.

Basil Bourque
347k130 gold badges951 silver badges1.3k bronze badges
answered Apr 10, 2011 at 8:47

1 Comment

Or Derby or HSQLDB. But I prefer H2. All three are relational database engines written in pure Java. All three can act as an embedded database.
1

If you are writing a desktop application in java using a simple SQL database such as SQLLite or HSQLDB is fine. I would not recommend using XML as such unless you use an XML Database such as BaseX or eXist but I am not sure what XML will bring you in this case. On the other hand I have been working for quite a while with ObjectDb and the simplicity of use and installation is staggering.

With any of these solutions you should not have too much difficulty creating an installer with your embedded database. The "problem" with the SQL and XML options is that you will need to learn how to query you database (SQL or Xpath...) and you will need to do the hard work of mapping your objects to the persistent representation manually unless you use a mapper such as Hibernate. You don't really want to do that if you are developing a small easily deployable application.

With an object database there is no need to learn SQL (although you can also query your database with OQL if you want to) and crucially, there is no mapping to do.

ObjectDB is a good option and it also is easily embeddable with one file to store the data.

Hope that helps, good luck with your project. Farid

answered Sep 20, 2011 at 23:15

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.