1

I am new here... and I have a problem!

I want to make an app where I need a database to store some data from a GUI. After I will finish my app, I want, for example, to share this. For the moment, I use MySQL database, but all my data are stored in separate files, not in my Java project and, if I share my app right now, you all you can't use this app because you don't have, probably, MySQL and because of other problems. Where I can find a good tutorial or if you can tell me what kind of database I can use to be embedded to my Java project and, after I will deploy my app, I want to run in any computer, without the needed to install a specific database. I hope you will understand what I want to get!

Have a wonderful day!

6
  • then u can use sqlite databse.look this javaworkspace.com/connectdatabase/connectSQLite.do Commented Nov 1, 2014 at 14:42
  • derby (also known as javadb) would be a good default choice. Commented Nov 1, 2014 at 14:45
  • Also have a look at H2 (h2database.com/html/quickstart.html) or HSQL (hsqldb.org/doc/guide/guide.html) Commented Nov 1, 2014 at 14:48
  • Check this out Commented Nov 1, 2014 at 14:49
  • 1
    I second the use of Derby -- the java classes for using it are part of Oracle's Java distribution -- no other libraries needed, no other installs, etc. The app will have to have a directory for the database to use, and you'll have to configure its location so that the app can find it regardless of the installation directory, etc. But it's free, involves no other installations or licenses, supports Hibernate, etc. Commented Nov 1, 2014 at 15:01

3 Answers 3

1

I would suggest either Apache Derby or H2. Both are 100% pure Java, can easily be embedded into your JAR file and have absolutely no external dependencies. (In terms of external programs or RDBMS).

However, putting the data into your jar file means that it is going to be static (unless you walk quite a mile with runtime JAR file manipulation). In this case, you might be better off using static data right away, be it in the form of property, xml, son or cvs files.

Sign up to request clarification or add additional context in comments.

Comments

1

The solution to your problem is to use an SQLite database. This functions like a relational database, but it exists inside a single .sqlite file that exists on the classpath. This means it gets bundled into the JAR file that is created and can be accessed when you distribute it.

One thing to note though, is that this makes several copies of the same database. This is negative because if you want to be able to change data, you'll need to run some kind of network-wide update. This is where an online MySQL server (or something similar) is useful. The client can connect to that single database, still get access to the data and if you need to change something, you can change it in one place.

2 Comments

except you still need sqlite installed separately.
I managed to solve my problem! I solve my problem with Java DB following this site codejava.net/java-se/jdbc/… I hope will help other people to solve their same problem with mine! Thank you stackoverflow!
0

Use H2 database. You can find documentation and quick start in start->h2 documentation once you installed the setup. h2.jar file is enough to use H2 db from java.

Comments

Your Answer

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.