|
Holger's Java API |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.antelmann.sql.JDBCBackup
public class JDBCBackup
allows to perform a backup/restore operation on a JDBC connection. Only the data will be backed up (in form of serialized Map instances). A restore will only work on already existing table structures. In case of foreign key constrains, be careful to use the right order of tables for backup operations. This implementation uses serialized objects, so that even BLOBs are supported.
ConnectionHelper,
ObjectOutputStream,
ObjectInputStream| Nested Class Summary | |
|---|---|
protected static class |
JDBCBackup.TableBegin
used to store the table name uniquely recognizable into the backup stream |
protected static class |
JDBCBackup.TableEnd
used to mark the end of a table for the backup stream |
| Constructor Summary | |
|---|---|
JDBCBackup(Connection con)
|
|
| Method Summary | |
|---|---|
void |
backup(File file,
String... tables)
|
void |
backup(OutputStream out,
Logger logger,
Monitor mon,
String... tables)
performs a backup of the table rows for the given table names to the given stream |
void |
backup(OutputStream out,
String... tables)
|
void |
copyTo(Connection target,
Logger logger,
Monitor backupMonitor,
Monitor restoreMonitor,
String... tables)
instead of just making a backup, the data is directly transferred to the target. |
void |
deleteRowsInOppositeOrder(String... tableNames)
deletes all tables in opposite order, so that the deletion logic is consistent to the table names provided with backup(File, String...). |
void |
restore(File file)
|
void |
restore(InputStream in)
|
void |
restore(InputStream in,
Monitor mon,
Logger logger,
boolean continueOnInsertionError)
note that before you run the restore, the relevant tables should ideally be made empty |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public JDBCBackup(Connection con)
| Method Detail |
|---|
public void copyTo(Connection target,
Logger logger,
Monitor backupMonitor,
Monitor restoreMonitor,
String... tables)
throws SQLException,
IOException
target - the target connection the data is to be written tologger - for logging purposesbackupMonitor - allows to monitor/cancel the backup operationrestoreMonitor - allows to monitor/cancel the restore operationtables - if null, all existing tables are copied; otherwise only the specified one in the given order
SQLException
IOException
public void backup(File file,
String... tables)
throws SQLException,
IOException
SQLException
IOException
public void backup(OutputStream out,
String... tables)
throws SQLException,
IOException
SQLException
IOException
public void backup(OutputStream out,
Logger logger,
Monitor mon,
String... tables)
throws SQLException,
IOException
out - the stream the data is to be written tologger - for logging purposesmon - allows to monitor and cancel the operationtables - if null or empty, all tables of the given connection will be backed up in the order returned by ConnectionHelper.getTableNames()
SQLException - when accessing the database fails
IOException - when writing to the stream fails
public void restore(File file)
throws SQLException,
IOException
SQLException
IOException
public void restore(InputStream in)
throws SQLException,
IOException
SQLException
IOException
public void deleteRowsInOppositeOrder(String... tableNames)
throws SQLException
backup(File, String...).
Normally, this method would be used before restoring an already filled database.
tableNames - if null, all tables will be deleted according to ConnectionHelper.getTableNames()
SQLException
public void restore(InputStream in,
Monitor mon,
Logger logger,
boolean continueOnInsertionError)
throws SQLException,
IOException
SQLException
IOExceptiondeleteRowsInOppositeOrder(String...)
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||