#include <dbconnection.h>
Public Types | |
enum | ConnectionStyle { DEFAULT, AUTO_COMMIT, PERSISTENT_READ_ONLY } |
Connection Style. More... | |
Public Methods | |
DbConnection (const LookString &theDatabaseName="", const LookString &theUser="", const LookString &thePassword="") | |
Constructor. More... | |
DbConnection (const DbConnection &theConnection) | |
Copy Constructor. More... | |
virtual | ~DbConnection () |
Destructor. | |
bool | Connect (void) |
Open a connection to the database. More... | |
void | Disconnect (void) |
Disconnect a connection from the database. More... | |
bool | Commit (void) const |
Commit a transaction. More... | |
bool | Rollback (void) const |
Rollback a transaction. More... | |
void | SetConnectionStyle (ConnectionStyle theConnectionStyle) |
ConnectionStyle | GetConnectionStyle (void) |
LOOK_DBC | GetSession (void) |
Get the session for use in interface layer functions. | |
Static Public Methods | |
void | TerminateConnections (void) |
Tidy up all my connections. More... | |
DbConnection* | GetGlobalConnection (void) |
Access to the global connection. More... | |
void | SetGlobalConnection (DbConnection *theConnection) |
Set the global connection. More... | |
Protected Attributes | |
LookString | itsDatabaseName |
LookString | itsUser |
LookString | itsPassword |
LOOK_DBC | itsSessionNumber |
bool | itIsConnected |
ConnectionStyle | itsConnectionStyle |
Static Protected Attributes | |
DbConnection* | itsGlobalConnection |
ConnectionList | itsConnections |
This class manages connections to a database. Methods are provided for connecting, disconnecting, managing transactions, and switching between different connections.
|
|
Constructor. The constructor makes a DbConnection object ready for use. It does not establish a connection - this is done via the Connect() method.
|
|
Copy Constructor. The copy constructor makes the new one based on the old one apart from the connection style.
|
|
Commit a transaction. Commit the current transaction on the current database connection.
|
|
Open a connection to the database.
|
|
Disconnect a connection from the database. The connection to the database is closed. There is no explicit commit or rollback.
|
|
Access to the global connection.
|
|
Rollback a transaction. Rollback the current transaction on the current database connection.
|
|
Set the global connection. The global connection is used by default by the library. There is no error checking (for example as to whether the connection is open). This must be set before you use DbQuery and DbField.
|
|
Tidy up all my connections. All connections are recorded by DbConnection. This disconnects and deletes them. Because of the delete, this should only be called when you no longer know about any of the connections, eg if you're in trouble. It will probably crash if you have any DbConnections on the stack.
|