4

I've been doing my homework ( like you asked ;) ) but I haven't found anything that really answers my needs, so here it goes:

I'm a junior Java developer and I'm working on a little project. The problem I'm currenctly experiencing is that I want to be able to store and retrieve data in a little database. I've tried to use textfiles, but they can only store data or retrieve all data at once, u can't select which data you want to retrieve. I'm looking for an alternative that doesn't need any installation or anything else, because I don't want my 'costumer' to download anything else but my application. I have tried HSQLDB, but that does need some installation...

So here's my question: Is there any database-alternative for java that doesn't need any installation AND where any data you want can be selected and retrieved?

JordyV
  • 389
  • 3
  • 12

4 Answers4

3

Apache derby is a part of JDK 6 onwards. You can use that.

It is called Java DB and bundled in the JDK.

If you go to JAVA_HOME/db you can find the installation.

Ajay George
  • 11,759
  • 1
  • 40
  • 48
2

You can use SQLite and the SQLite JDBC Adapter.

njallam
  • 476
  • 9
  • 23
tbraun89
  • 2,246
  • 3
  • 25
  • 44
  • Have tried SQLite, but that doesn't seem to work very well on the 'select any data I want' part, and still needs to be downloaden by the user aswell – JordyV Nov 01 '12 at 12:18
  • 1
    You can package SQLite with your application. It is probably the most commonly used solution to your problem. – lynks Nov 01 '12 at 12:20
  • It's a file databse, so you only need to distribute the adapter and the databse file with you application. Your cusomer dont need to download or install anything. – tbraun89 Nov 01 '12 at 12:20
  • ow, didn't know it was possible to distribute the DB file with your application. Thanks :)! – JordyV Nov 01 '12 at 12:22
  • 1
    FYI, SQLite is bundled e.g. in Firefox and Opera for their internal storage (things like bookmarks, history etc.) for fast querying. – jakub.g Nov 01 '12 at 12:47
  • I've tried to connect my SQLite DB to eclipse, but it won't find the .jar file. I've searched the internet for tutorials or other help, but nothing seems to fit my needs. Any help please? As I said, I'm a junior, so I don't know alot about JDBC.. Also, alot of tutorials that seemed to have helped people in the past are unable to use nowadays, because the .jar file you have to download and the link to a good tutorial doesn't exist anymore.. I really need help on this – JordyV Nov 02 '12 at 02:19
  • Maybe this will help you: http://stackoverflow.com/questions/179024/adding-a-jar-to-an-eclipse-java-library – tbraun89 Nov 04 '12 at 15:34
1

You can use Microsoft Access. If Microsoft Office is installed on your machine(assuming you are using Windows OS) then Microsoft Access might also have been installed. Just check it if its already there and if it is there then it is good to start databse related programming in java using MS Access.

Abubakkar
  • 15,488
  • 8
  • 55
  • 83
  • well, the problem is, I have MS Access, and I have already used it for a school project last year, but my costumer doesn't have MS access, so that's out of the question, but thanks anyway! – JordyV Nov 01 '12 at 12:12
  • 1
    Please *don't* install Access. It uses non-standard SQL syntax from Microsoft, which annoys everyone I know who worked with other databases like MySQL, Oracle, MS SQL Server etc. before. Also you risk vendor lock-in, as it's Windows-only solution (well, MS SQL Server also is, but it's much better and is used in real heavy business as a part of SQL Server + .NET stack, so it's a different pair of shoes). I recommened SQLite personally. – jakub.g Nov 01 '12 at 12:36
1

Have you had a look at Lucene? It's much like a database in that you can query your list of 'documents' (sets of key-value pairs) in lots of nice complex ways. It's also very fast.

lynks
  • 5,599
  • 6
  • 23
  • 42
  • will keep that in mind if I can't figure out how apache and SQLite work ;) – JordyV Nov 01 '12 at 12:27
  • remember that it's called *apache derby*, Apache is the foundation, my suggestion Lucene is also part of the apache foundation, as is of course the apache web browser. – lynks Nov 01 '12 at 12:33
  • Lucene is nice, but it's rather to be used by applications like search engines. Also, it's a bit hard at the beginning. It's more a *tool* to create your own highly personalized search engine. It takes quite some code to make it work. I think SQL-based solution might better fit his needs (but that depends what kind of app he's developing). I think learning curve for SQL is easier than the one of Lucene. – jakub.g Nov 01 '12 at 12:42
  • 2
    @jakub.g yep I totally agree, tbraun's answer of SQLite is by far the best. I was just mentioning Lucene for completeness. – lynks Nov 01 '12 at 12:54