|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface DumpFileManager
A class that can save dumps into a file and then load them back again into memory.
After a Dump object is created using DatabaseConnection.dump(), it can be saved into
a file using a DumpFileManager. A Dump only contains database structure, not data,
because the amount of data may be so big that it will not fit into the memory.
So when a Dump is exported using exportDump(), first all information contained in it
is saved, and then the Dump is used to download the rest of the data from the database.
The same is with loading a dump - first its structure is loaded into a Dump object using
importDump(), and then in restore() all data is read from the same file after the structure
is created in the database.
Usage example:
DatabaseConnectorFactory fac = DatabaseConnectorFactory.getInstance(); DatabaseConnector conn = fac.createConnector("net.sourceforge.connect.connectors.MysqlConnector"); DumpFileManager fman = new BinaryFileManager(); try { // dump base1 into dump.zip conn.connect("jdbc:mysql://database.myserver.com/base1", "admin", "AdMiNpAsS"); Dump dump = conn.dump(); fman.exportDump(dump, new File("dump.zip"), DumpFileManager.CompressionMethod.ZIP); conn.disconnect(); // restore dump.zip into base2 conn.connect("jdbc:mysql://database.myserver.com/base2", "admin", "AdMiNpAsS"); Dump dump2 = fman.importDump(new File("dump.zip"), DumpFileManager.CompressionMethod.ZIP); conn.restore(dump2); dump2.closeFileReader(); conn.disconnect(); } catch (SQLException e) { e.printStackTrace(); }
Nested Class Summary | |
---|---|
static class |
DumpFileManager.CompressionMethod
|
Method Summary | |
---|---|
void |
exportDump(Dump dump,
java.io.File file,
DumpFileManager.CompressionMethod compress)
Saves a backup of the database represented in the dump object into the specified file. |
Dump |
importDump(java.io.File file,
DumpFileManager.CompressionMethod compress)
Loads the database structure as a Dump object from the specified file. |
Method Detail |
---|
void exportDump(Dump dump, java.io.File file, DumpFileManager.CompressionMethod compress)
dump
- a database dump created using DatabaseConnector.dump() methodfile
- a file in which the backup will be storedcompress
- compression method used to compress the file (zip, gzip or none)Dump importDump(java.io.File file, DumpFileManager.CompressionMethod compress)
file
- a file from which the backup should be readcompress
- compression method used to decompress the file (zip, gzip or none)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |