Transferring Read-Only Databases to Archive (Jar or Zip) Files
Transferring Read-Only Databases to Archive (Jar or Zip) Files
Once a database has been created in Derby, it can be stored in a jar or zip file and continue to be accessed by Derby in read-only mode. This allows a read-only database to be distributed as a single file instead of as multiple files within a directory and to be compressed. In fact, a jar or zip file can contain any number of Derby databases and can also contain other information not related to Derby, such as application data or code.
You cannot store the derby.properties file in a jar or zip file.
To create a jar or zip file containing one or more Derby databases:
- Follow the instructions for creating a database for use on read-only media. See Creating and Preparing the Database for Read-Only Use.
- From the directory that contains the database folder, archive the database directory and its contents. For example, for the databasesales that lives in the system directory C:\london, issue the command from london. Do not issue the command from inside the database directory itself.
For example, archive the database folder and its contents using the JAR program from the JDK. You can use any zip or jar tool to generate the archive.
This command archives the database directory sales and its contents into a compressed jar file called dbs.jar.
cd C:\london jar cMf C:\dbs.jar sales
You can add multiple databases with jar. For example, this command puts the sales databases and the boiledfood database (in the subdirectory products) into the archive.
cd C:\london jar cMf C:\dbs.jar sales products\boiledfood
The relative paths of the database in the jar need not match their original relative paths. You can do this by allowing your archive tool to change the path, or by moving the original databases before archiving them.
The archive can be compressed or uncompressed, or individual databases can be uncompressed or compressed if your archive tool allows it. Compressed databases take up a smaller amount of space on disk, depending on the data loaded, but are slower to access.
Once the database is archived into the jar or zip file, it has no relationship to the original database. The original database can continue to be modified if desired.
Previous Page
Next Page
Table of Contents
Index