|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.almworks.sqlite4java.SQLiteBackup
public class SQLiteBackup
SQLiteBackup wraps an instance of SQLite database backup, represented as sqlite3_backup*
in SQLite C API.
Use example:
SQLiteBackup backup = connection.initializeBackup(new File("filename")); try{ while(!backup.isFinished()) { backup.backupStep(2); } } finally { backup.dispose(); }
Unless a method is marked as thread-safe, it is confined to the thread that has opened the connection to source database. Calling a confined method from a different thread will result in exception.
Method Summary | |
---|---|
boolean |
backupStep(int pagesToBackup)
Copy up to pagesToBackup pages from source database to destination. |
void |
dispose()
Dispose this backup instance and connection to destination database. |
void |
dispose(boolean disposeDestination)
Dispose this backup instance and, if disposeDestination is true, connection to destination database. |
SQLiteConnection |
getDestinationConnection()
Returns connection to destination database, that was opened by SQLiteConnection.initializeBackup(java.lang.String, java.io.File, int) . |
int |
getPageCount()
Returns the total number of pages in source database. |
int |
getRemaining()
Returns the number of pages still to be backed up. |
boolean |
isFinished()
Checks whether back up 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 will be modified during backup by connection other than source connection, then backup will be restarted by the next call to backupStep. Else if source database will be modified by source connection itself, then destination database will be updated without restarting.
pagesToBackup
- - the number of page, that will be backed up during this step.
SQLiteException
- if SQLite return an error or if the call violates the contract of this class
SQLiteBusyException
- if SQLite cannot established SHARED_LOCK on source DB or RESERVED_LOCK on
destination DB or source connection is used to write to DB. In these cases call to backupStep can be
retried laterpublic boolean isFinished()
backupStep(int)
has returned true.public SQLiteConnection getDestinationConnection()
SQLiteConnection.initializeBackup(java.lang.String, java.io.File, int)
.
NB! If you get connection to destination database, you should care about disposing order of backup and that connection. That connection must be disposed after disposing SQLiteBackup instance.
public void dispose(boolean disposeDestination)
disposeDestination
is true, connection to destination database.
disposeDestination
- if true, connection to destination database will be disposed.public void dispose()
This is convenience method, equivalent to dispose(true)
.
public int getPageCount() throws SQLiteException
SQLiteException
- if called from differed thread or if source or destination connection are disposedpublic int getRemaining() throws SQLiteException
SQLiteException
- if called from differed 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 |