Transferring read-only databases to archive (jar or zip) files Once a database has been created in , it can be stored in a jar or zip file and continue to be accessed by in read-only mode. Zip filesdatabases in Archiving read-only databasesRead-only databasesarchiving to jar or zip filesJar filesdatabases in

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 databases and can also contain other information not related to , 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 databases:

  1. Create a database for use on read-only media.
  2. From the directory that contains the database folder, archive the database directory and its contents. For example, for the database sales 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.