BD for distribution together with java application

Asked

Viewed 504 times

6

Good evening guys, I have a small JAVA application in which some data is entered. I would like to distribute it with an DBMS that does not require download and installation/configuration.

I have been researching and found HSQLDB, but I read in some places that if the database is distributed inside the JAR it will be read-only. Is there any way to make the database available together with the application and allow data entry? If not possible, there is one that supports this?

3 answers

3


Whatever your database, it will need to save the application data somewhere on your hard drive. JAR files are not designed to be modified while being read or run, they are designed to be read and run. And even if you could do that with JAR files, it would have to be a special DBMS capability.

Because of this, I recommend databases that save the information in local files. Of these I can cite HSQLDB, H2, Derby and Firebird, as they do not require installation. I think Sqlite can also serve (I’m not sure). There must be others.

However, again I come to emphasize that anyone you use will need to be able to write and modify files on disk.

Finally, it is no problem to distribute your DBMS inside the JAR. The problem is that you try to save the data inside the JAR.

  • Thank you! If it is possible to distribute any of these Dbms that you cited in the same JAR folder and it is possible to enter and recover data by JAR code, then my problem is solved!

3

Yes, if you distribute the database inside the jar, it will be read only, however, there are banks like HSQLDB And Sqlite, which create files referring to external database to your jar, in the same directory or in another you define, if you read here you will see that hsldb creates your database in a file .script and the sqlite creates a file extended .db.

There are numerous tutorials teaching how to manipulate such banks, even the bank’s own documentation is query material. I recommend this tutorial, if you opt for HSQLDB, although a little old, it will give you a good basis to start coding and modeling the database.

  • Thank you! If it is possible to distribute any of these Dbms that you cited in the same JAR folder and it is possible to enter and recover data by JAR code, then my problem is solved!

1

Inside your jar only goes the database driver.

In your program you’re going to have him set up a bank externally. It can be in the same jar folder, or in a common path like disk C: (in case of Windows, but not recommend) or user folder (most recommended). The important thing is to be a folder that you have write permission for.

You can create initial data if necessary or already distribute the initial database along with your system.

This applies to the various banks cited as HSQLDB, Derby, H2 and Firebird

  • 1

    Thank you! If it is possible to distribute any of these Dbms that you cited in the same JAR folder and it is possible to enter and recover data by JAR code, then my problem is solved!

  • It is possible yes.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.