BD for distribution along with java application

6

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

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

    
asked by anonymous 05.11.2015 / 04:33

3 answers

3

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

Because of this, I recommend databases that save information to local files. Of these I can mention HSQLDB, H2, Derby and Firebird, since they do not need the installation. I think SQLite can also serve (I'm not sure). There must be others.

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

Finally, it's okay to distribute your DBMS inside the JAR. The problem is with you trying to save the data within that same JAR.

    
05.11.2015 / 10:09
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 a database external to your jar, in the same directory or in another you set, if you read here you will see that hsldb creates your database in a .script file, and sqlite creates a file with extension% with%.

There are numerous tutorials teaching how to manipulate such banks, even the bank's own documentation is reference material. I recommend this tutorial , if you choose HSQLDB, although a bit old, it will give you a good base to start the coding and modeling of the bank.

    
05.11.2015 / 10:33
1

Inside your jar will only go the database driver.

In your program you will have it created externally. It can be in the same jar folder, or in a common path as the C: disk (in case of Windows, but I do not recommend it) or in the user folder (most recommended). The important thing is to be a folder that you are allowed to write.

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

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

    
05.11.2015 / 12:06