nsISupports
Last changed in Gecko 1.9 (Firefox 3)nsIFile backupDatabaseFile(in |
openDatabase(in |
openSpecialDatabase(in string aStorageKey); |
openUnsharedDatabase(in |
This method makes a backup of the specified file. The database should not be open, or you should ensure that no database activity is happening when you call this method. The filename provided is only used as a suggestion. If the filename is already taken, attempts will be made to ensure that it is unique. The actual backup file is returned, and the resulting filename can be obtained from that.
nsIFile backupDatabaseFile(
in nsIFile aDBFile,
in AString aBackupFileName,
in nsIFile aBackupParentDirectory Optional
);
aDBFile
aBackupFileName
aBackupParentDirectory
OptionalAn nsIFile
object representing the newly-created backup file.
Opens a database connection to the specified file. The specified file is created if it does not already exist. If this method throws NS_ERROR_FILE_CORRUPTED
, it's recommended that you call mozIStorageService.backupDatabaseFile()
to back up the database so that user data is not lost (although we have no way of recovering this data yet).
Consumers should check mozIStorageConnection.connectionReady
to ensure that they can use the database. If this value is false
, it is strongly recommended that the database be backed up with mozIStorageConnection.backupDB()
so user data is not lost. And then the database can be opened again with the mozIStorageService.openDatabase()
method.
Warning: If you have more than one connection to a file, you must use the exact same name for the file each time, including case. The sqlite code uses a simple string comparison to see if there is already a connection. Opening a connection to "Foo.sqlite" and "foo.sqlite" will corrupt your database.
If your database contains virtual tables (for example, for full-text indexes), you must use mozIStorageService.openUnsharedDatabase()
to open it, since those tables are not compatible with a shared cache. If you use this method to open a database containing virtual tables, it will think the database is corrupted and throw NS_ERROR_FILE_CORRUPTED
.
mozIStorageConnection openDatabase( in nsIFile aDatabaseFile );
aDatabaseFile
nsIFile
indicating the database file to open.A mozIStorageConnection
representing the connection to the opened database file.
NS_ERROR_FAILURE
NS_ERROR_FILE_CORRUPTED
NS_ERROR_OUT_OF_MEMORY
Opens a connection to a named special database storage that identifies the type of storage requested.
mozIStorageConnection openSpecialDatabase( in string aStorageKey );
aStorageKey
A new mozIStorageConnection
providing access to the requested database.
NS_ERROR_INVALID_ARG
aStorageKey
is invalid.Opens a database connection to the specified file without using a shared cache. If this method throws NS_ERROR_FILE_CORRUPTED
, it's recommended that you call mozIStorageService.backupDatabaseFile()
to back up the database so that user data is not lost (although we have no way of recovering this data yet).
Each connection uses its own sqlite cache, which is inefficient, so you should use openDatabase()
instead of this method unless you need a feature of SQLite that is incompatible with a shared cache, like virtual table and full text indexing support. If cache contention is expected, for instance when operating on a database from multiple threads, using unshared connections may be a performance win.
Warning: If you have more than one connection to a file, you must use the exact same name for the file each time, including case. The sqlite code uses a simple string comparison to see if there is already a connection. Opening a connection to "Foo.sqlite" and "foo.sqlite" will corrupt your database.
mozIStorageConnection openUnsharedDatabase( in nsIFile aDatabaseFile );
aDatabaseFile
nsIFile
indicating the database file to open.A mozIStorageConnection
representing the connection to the opened database file.
NS_ERROR_FAILURE
NS_ERROR_FILE_CORRUPTED
NS_ERROR_OUT_OF_MEMORY