I cannot understand how distributing Java programs that use a database works. Let's say I am using Derby as RDBMS and I want to store tasks and calendar entries in a database. I want each user of the program to have a local database.

But I don't understand how in-memory databases are supposed to work. Should I write a script so that the first time my program is launched it creates a database and empty tables? Or will they be already created during the installation of the program?

有帮助吗?

解决方案

If your program wants to store the user's tasks and calendar entries in a database, you probably don't want to use an in-memory database, because the in-memory database disappears when your program exits.

Rather, you want to use an ordinary persistent Derby database, which will store the user's data in files in a folder on the filesystem.

You do indeed have to create the database and issue the CREATE TABLE etc. statements to create the tables in that database. You could provide that as a separate script, or you could have your program issue those statements itself.

Tables are not automatically created, though; you have to issue the CREATE TABLE statements one way or another.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top