|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.almworks.sqlite4java.SQLiteBackup
public class SQLiteBackup
SQLiteBackup wraps an instance of SQLite database backup, represented as sqlite3_backup*
in SQLite C API.
Usage example:
SQLiteBackup backup = connection.initializeBackup(new File("filename")); try { while (!backup.isFinished()) { backup.backupStep(32); } } finally { backup.dispose(); }
Unless a method is marked as thread-safe, it is confined to the thread that has opened the connection to the source database. Calling a confined method from a different thread will result in exception.
SQLiteConnection.initializeBackup(java.lang.String, java.io.File, int)
Method Summary | |
---|---|
boolean |
backupStep(int pagesToBackup)
Copy up to pagesToBackup pages from source database to destination. |
void |
dispose()
Disposes this backup instance and connection to the destination database. |
void |
dispose(boolean disposeDestination)
Dispose this backup instance and, if disposeDestination is true, dispose the connection to
the destination database as well. |
SQLiteConnection |
getDestinationConnection()
Returns connection to the destination database, that was opened by SQLiteConnection.initializeBackup(java.lang.String, java.io.File, int) . |
int |
getPageCount()
Returns the total number of pages in the source database. |
int |
getRemaining()
Returns the number of pages still to be backed up. |
boolean |
isFinished()
Checks whether the backup was successfully finished. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public boolean backupStep(int pagesToBackup) throws SQLiteException, SQLiteBusyException
If source database is modified during backup by any connection other than the source connection, then the backup will be restarted by the next call to backupStep. If the source database is modified by the source connection itself, then destination database is be updated without backup restart.
pagesToBackup
- the maximum number of pages to back up during this step, or negative number to back up all pages
SQLiteException
- if SQLite returns an error or if the call violates the contract of this class
SQLiteBusyException
- if SQLite cannot establish SHARED_LOCK on the source database or RESERVED_LOCK on
the destination database or source connection is currently used to write to the database.
In these cases call to backupStep can be retried later.public boolean isFinished()
backupStep(int)
has returned true.public SQLiteConnection getDestinationConnection()
SQLiteConnection.initializeBackup(java.lang.String, java.io.File, int)
.
Important! If you call this method, you should be careful about disposing the connection you got. You should only dispose it after disposing SQLiteBackup instance, otherwise the JVM might crash.
public void dispose(boolean disposeDestination)
disposeDestination
is true, dispose the connection to
the destination database as well.
You might want to pass false
to this method to subsequently call getDestinationConnection()
and perform any actions on the fresh backup of the database, then dispose it yourself.
disposeDestination
- if true, connection to the destination database will be disposedpublic void dispose()
This is a convenience method, equivalent to dispose(true)
.
dispose(boolean)
public int getPageCount() throws SQLiteException
SQLiteException
- if called from a different thread or if source or destination connection are disposedpublic int getRemaining() throws SQLiteException
SQLiteException
- if called from a different thread or if source or destination connection are disposedpublic java.lang.String toString()
toString
in class java.lang.Object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |