SQLDatabase Class Reference
A class representing a session with an embedded SQL database.
More...
#include <SQLDatabase.h++>
List of all members.
Public Member Functions |
| | SQLDatabase () |
| | Construct a new SQLDatabase object.
|
| virtual | ~SQLDatabase () throw () |
| | Destructor.
|
| String | getVersion () throw () |
| | Get the version of the underlying SQLite database software.
|
| void | open (const String &path, bool create=true, bool readOnly=false) throw (IOException) |
| | Open the database.
|
| void | close () throw () |
| | Close the database.
|
| uint_t | executeSQL (const String &sql) throw (SQLException, InterruptedException) |
| | Execute an SQL statement.
|
| void | interrupt () throw (SQLException) |
| | Interrupt any currently-executing SQL statement.
|
| bool | isAutoCommit () throw (SQLException) |
| | Test if the database is currently in auto-commit mode.
|
| SQLQuery * | prepareQuery (const String &sql) throw (SQLException) |
| | Create a query for the given SQL statement.
|
| int64_t | getGeneratedKey () throw (SQLException) |
| | Get the generated key created by the last SQL "INSERT" statement.
|
| uint_t | getModifiedRowCount () throw (SQLException) |
| | Get the number of rows modified by the last SQL statement.
|
| void | begin () throw (SQLException) |
| | Begin a transaction.
|
| void | commit () throw (SQLException, TimeoutException) |
| | Commit a pending transaction.
|
| void | rollback () throw (SQLException, TimeoutException) |
| | Roll back a pending transaction.
|
Protected Member Functions |
| virtual bool | onProgress () |
| | A callback that's invoked periodically while a SQL statement is being executed.
|
| virtual void | onCommit () |
| | A callback that's invoked each time a transaction is committed.
|
| virtual void | onRollback () |
| | A callback that's invoked each time a transaction is rolled back.
|
Detailed Description
A class representing a session with an embedded SQL database.
The class can be subclassed to provide custom implementations for the three callback methods.
- Author:
- Mark Lindner
Constructor & Destructor Documentation
Destructor.
Closes the database, if it is open.
Member Function Documentation
Begin a transaction.
Transactions cannot be nested.
- Exceptions:
-
Close the database.
Any pending uncommitted transactions will be rolled back.
Commit a pending transaction.
- Exceptions:
-
| SQLException | If a database error occurs. |
| TimeoutException | If a timeout occurs while waiting for database locks. The call should be retried in this case. |
Execute an SQL statement.
- Parameters:
-
| sql | The statement to execute. |
- Returns:
- The number of rows that were affected by the statement.
- Exceptions:
-
Get the generated key created by the last SQL "INSERT" statement.
- Returns:
- The generated key.
- Exceptions:
-
Get the number of rows modified by the last SQL statement.
| String getVersion |
( |
|
) |
throw () |
Get the version of the underlying SQLite database software.
Interrupt any currently-executing SQL statement.
The corresponding method will throw an InterruptedException.
- Exceptions:
-
Test if the database is currently in auto-commit mode.
Auto-commit mode is on by default if a transaction is not currently in progress.
- Exceptions:
-
| void onCommit |
( |
|
) |
[protected, virtual] |
A callback that's invoked each time a transaction is committed.
The default implementation does nothing.
| bool onProgress |
( |
|
) |
[protected, virtual] |
A callback that's invoked periodically while a SQL statement is being executed.
The default implementation does nothing and returns true.
- Returns:
- true if the in-progress operation should continue, or false if it should be interrupted.
| void onRollback |
( |
|
) |
[protected, virtual] |
A callback that's invoked each time a transaction is rolled back.
The default implementation does nothing.
| void open |
( |
const String & |
path, |
|
|
bool |
create = true, |
|
|
bool |
readOnly = false | |
|
) |
| | throw (IOException) |
Open the database.
- Parameters:
-
| path | The pathname of the database file to open. |
| create | A flag indicating whether the database should be created if it does not exist. |
| readOnly | A flag indicating whether the database should be opened read-only. |
- Exceptions:
-
Create a query for the given SQL statement.
- Parameters:
-
- Returns:
- The new SQLQuery. The caller is responsible for deleting this object before closing the database.
- Exceptions:
-
Roll back a pending transaction.
- Exceptions:
-
| SQLException | If a database error occurs. |
| TimeoutException | If a timeout occurs while waiting for database locks. The call should be retried in this case. |
The documentation for this class was generated from the following files: