Should I auto-record my database tables in code or pre-initialize during installation?

I have a Java application that uses an Apache Derby database with a built-in driver. Right now, during the installation process, I am running scripts to create SQL from the process.

So, when the application starts, the tables already exist. Recently, I started thinking that it would be better to have my SQL script in the classpath or something else, load it and follow all the instructions so that the tables are created at startup. The database itself can be automatically called if it is missing, so it looks like it might be less error prone by the way the tables load first.

My question is: Perhaps I will have problems detecting the existence / creation of tables in the process when the application starts or waiting for them to be configured correctly by my installation?

+3
source share
3 answers

I think your first step should be to create them during installation and work gracefully at runtime. Then the flesh, due to failure, gracefully parted to self-repair.

Detecting and processing error conditions in a process is IMO, always better than anticipating (expecting) and failing.

, "" . , . , . , /, , ​​. , , .

, , , . , , / , .

( , ), , . , , , , , , .

+1

, . , , , ( , , ).

0

, , , . , . , ?

, , , . , (,/CREATETABLES), , .

, , (, ) . .

0

Source: https://habr.com/ru/post/1762483/


All Articles