Typically, these procedures are used to speed up the copy operation involved in an online backup.
In this scenario, Derby does not perform the copy operation for you. You use the SYSCS_UTIL.SYSCS_FREEZE_DATABASE procedure to lock the database, and then you explicitly copy the database directory by using operating system commands.
For example, because the UNIX tar command uses operating system file-copying routines, and the SYSCS_UTIL.SYSCS_BACKUP_DATABASE procedure uses Java I/O calls with additional internal synchronization that allow updates during the backup, the tar command might provide faster backups than the SYSCS_UTIL.SYSCS_BACKUP_DATABASE procedure.
To use operating system commands for online database backups, call the SYSCS_UTIL.SYSCS_FREEZE_DATABASE system procedure. The SYSCS_UTIL.SYSCS_FREEZE_DATABASE system procedure puts the database into a state in which it can be safely copied. After the database has been copied, use the SYSCS_UTIL.SYSCS_UNFREEZE_DATABASE system procedure to continue working with the database. Only after SYSCS_UTIL.SYSCS_UNFREEZE_DATABASE has been specified can transactions once again write to the database. Read operations can proceed while the database is frozen.
The following example demonstrates how the freeze and unfreeze procedures are used to surround an operating system copy command:
public static void backUpDatabaseWithFreeze(Connection conn) throws SQLException { Statement s = conn.createStatement(); s.executeUpdate( "CALL SYSCS_UTIL.SYSCS_FREEZE_DATABASE()"); //copy the database directory during this interval s.executeUpdate( "CALL SYSCS_UTIL.SYSCS_UNFREEZE_DATABASE()"); s.close(); }