In order to make the reconstruction of a database possible, we are going to use our own binary format. However it is not the only option. We have decided to use highly flexible approach and let our system handle other data formats when an appropriate plugin is added. When the proper plugin is loaded, the system will be able to create the image of a database in a form of a text file as standard SQL commands. Thanks to this feature this application not only enables you to reconstruct a database, but even may give you the possibility to convert one type of database into another (although that may require a few manual changes in the sql commands, depending on the types of the databases).
Databases tend to store huge amount of data, lots of megabytes let's say. As a result, the output back-up file will be probably quite large, regardless of the data format chosen by the user. Downloading such large files is very uncomfortable, especially when your internet connection is not very fast. If you consider the content of a back-up, it is easy to notice that it mostly contains repeatable strings that make it perfect to compress. Java makes files compression very easy. Since the compression functions are available through the standard java package java.util.zip you do not need any external libraries. There are two compression alghoritms: one uses ZIP format, the other - GZIP. To make the behaviour of the system more flexible, we have decided to let the user chose which of these methods he prefers. User can also reject this offer and create an uncompressed file if its size is not too big. Distinguishing between zip and gzip formats has been caused by different preferences of Windows and linux administrators: those working under Windows would probably prefer *.zip file whereas those working under linux would probably choose *.gz.
The output file will be optionally encrypted. However the easiest way to obtain safety will be the usage of the system in conjunction with the ssl tunnel. This method is highly recommended.
Database servers use many different relational database management systems. Although all of them implement common SQL standard, there are some slight differences among the implementation of some details and the possibilities each one provides, for example the most popular database management MySQL had not been able to work with views, storage procedures and triggers till last October. Therefore, one cannot write one universal module that would download data from all database types. We can of course restrict to some ranges of elements common for all databases, but this approach would result in data incompleteness and make such dump completely useless. We can also choose just a few database types, we plan to work with and then make an individual approch towards each of them. We have decided to create a part of the system responsible for downloading data so as to minimalize the implementation time and include as many datatypes as possible. To achieve that point, a special group of classes will be used:
Owing to this solution, functions identical for all databases can be implemented just once in the main class, whereas all other specific functions can be implemented in subclasses. User can also make advantage of this main class when he wants to receive a backup of a database our system does not support. However we can not guarantee the success of such an operation.
In order to give users the possibility to expand the number of system's database types, we are going to make the system create the list of classes that deal with databases dynamically by searching through the appropriate package to find classes which inherit from the main connection class. As a result, you will not need to modify original *.jar files. All you need to do is provide your own jar package with your own classes. The system should detect them.
JNDI takes care of database connections, the application connects to databases by taking a DataSource from JNDI
At the beginning system creates the structure of tables, then fills the tables with data, and in the last step it adds constraints.
In order to recognize tables' names in a database we are going to use so called metadata (DatabaseMetaData class).