#include <db.h>
Inheritance diagram for DB::Connection:

Public Types | |
| typedef Connection *(*) | Connection_Creator (void) |
| READ_UNCOMMITTED | |
| READ_COMMITTED | |
| REPEATABLE_READ | |
| SERIALIZABLE | |
| enum | TRANS_MODE { READ_UNCOMMITTED, READ_COMMITTED, REPEATABLE_READ, SERIALIZABLE } |
Public Member Functions | |
| virtual | ~Connection (void) |
| virtual bool | open (const char *database, const char *host, const int port, const char *user, const char *pass)=0 |
| virtual bool | close (void)=0 |
| virtual bool | isConnected (void)=0 |
| virtual bool | execute (const char *sql)=0 |
| virtual ResultSet * | executeQuery (const char *sql)=0 |
| virtual char * | escape (const char *)=0 |
| virtual const char * | unixtimeToSql (const time_t)=0 |
| virtual const unsigned long | insertId (void)=0 |
| virtual bool | beginTrans (void)=0 |
| virtual bool | commitTrans (void)=0 |
| virtual bool | rollbackTrans (void)=0 |
| virtual bool | setTransactionMode (const enum TRANS_MODE mode)=0 |
| virtual unsigned int | errorno (void) const =0 |
| virtual const char * | errormsg (void) const =0 |
| virtual const char * | version (void) const =0 |
Static Public Member Functions | |
| static Connection * | factory (const char *db_dll_name) |
The classes are partially thread-safe in that a Connection object may be used in a single thread, but many Connection objects may be created in different threads. This is due to most database implementations following this same style of interface. For best portability, one should follow this same style of usage.
Definition at line 87 of file db.h.
| typedef Connection*(*) DB::Connection::Connection_Creator(void) |
| READ_UNCOMMITTED | |
| READ_COMMITTED | allows dirty reads, but fastest |
| REPEATABLE_READ | default postgres, mssql, and oci8 |
| SERIALIZABLE | slowest and most restrictive |
Definition at line 196 of file db.h.
00196 { 00197 READ_UNCOMMITTED, 00198 READ_COMMITTED, 00199 REPEATABLE_READ, 00200 SERIALIZABLE 00201 };
| virtual DB::Connection::~Connection | ( | void | ) | [inline, virtual] |
| virtual bool DB::Connection::beginTrans | ( | void | ) | [pure virtual] |
Begins a new transaction. If for some reason it fails, false will be returned (for instance, if the underlying driver does not support transactions.)
Implemented in DB::MySQL_Connection, and DB::Sqlite3_Connection.
| virtual bool DB::Connection::close | ( | void | ) | [pure virtual] |
Close the database connection
Implemented in DB::MySQL_Connection, and DB::Sqlite3_Connection.
| virtual bool DB::Connection::commitTrans | ( | void | ) | [pure virtual] |
Attempts to commit the current transaction
Implemented in DB::MySQL_Connection, and DB::Sqlite3_Connection.
| virtual const char* DB::Connection::errormsg | ( | void | ) | const [pure virtual] |
Returns a textual representation of the last error to occur. The value returned should NOT be freed.
Implemented in DB::MySQL_Connection, and DB::Sqlite3_Connection.
| virtual unsigned int DB::Connection::errorno | ( | void | ) | const [pure virtual] |
Returns the last error code to occur.
Implemented in DB::MySQL_Connection, and DB::Sqlite3_Connection.
| virtual char* DB::Connection::escape | ( | const char * | ) | [pure virtual] |
Returns a database specific escaped string from the input. The string returned must be freed by the caller. This is used by the Query class.
Implemented in DB::MySQL_Connection, and DB::Sqlite3_Connection.
Referenced by DB::qstr_impl().
| virtual bool DB::Connection::execute | ( | const char * | sql | ) | [pure virtual] |
Executes a query to the database, discarding any result data. This function is typically used for non-SELECT statements.
| sql |
Implemented in DB::MySQL_Connection, and DB::Sqlite3_Connection.
| virtual ResultSet* DB::Connection::executeQuery | ( | const char * | sql | ) | [pure virtual] |
Executes a query to the database which returns row data. The row data is manipulated using the ResultSet object returned by this method. If the database wasn't able to return row data or an error occurs, then zero is returned. Therefore be careful to check the returned value, before using it - or a seg. fault is possible!
| sql |
Implemented in DB::MySQL_Connection, and DB::Sqlite3_Connection.
| static Connection* DB::Connection::factory | ( | const char * | db_dll_name | ) | [inline, static] |
Factory method for creating a new Connection object for a database connection. This method shields the logic for DLL manipulation from the caller.
Warning: The returned Connection pointer may be NULL if an error condition occurred!
| db_dll_name | The database type to create |
Definition at line 250 of file db.h.
References open().
00251 { 00252 ACE_DLL dll; 00253 00254 int ret = dll.open(ACE_TEXT(db_dll_name), 00255 ACE_DEFAULT_SHLIB_MODE, 00256 0); 00257 if (ret != 0) { 00258 ACE_ERROR_RETURN((LM_ERROR, "%p", "dll.open"), 0); 00259 } 00260 Connection_Creator cc; 00261 void *void_ptr = dll.symbol(ACE_TEXT("create_connection")); 00262 ptrdiff_t tmp = reinterpret_cast<ptrdiff_t>(void_ptr); 00263 cc = reinterpret_cast<Connection_Creator>(tmp); 00264 if (cc == NULL) { 00265 ACE_ERROR_RETURN((LM_ERROR, "%p", "dll.symbol"), 0); 00266 } 00267 return (cc()); 00268 }
| virtual const unsigned long DB::Connection::insertId | ( | void | ) | [pure virtual] |
Returns the last SQL INSERT unique identifier if the underlying database supports this feature.
Implemented in DB::MySQL_Connection, and DB::Sqlite3_Connection.
| virtual bool DB::Connection::isConnected | ( | void | ) | [pure virtual] |
Attempts to tell if we are still connected to the database.
Implemented in DB::MySQL_Connection, and DB::Sqlite3_Connection.
| virtual bool DB::Connection::open | ( | const char * | database, | |
| const char * | host, | |||
| const int | port, | |||
| const char * | user, | |||
| const char * | pass | |||
| ) | [pure virtual] |
Open a connection to a database.
| database | Database name. Sqlite3 uses this for the filename. | |
| host | Hostname | |
| port | Port | |
| user | Username | |
| pass | Password |
Implemented in DB::MySQL_Connection, and DB::Sqlite3_Connection.
Referenced by factory().
| virtual bool DB::Connection::rollbackTrans | ( | void | ) | [pure virtual] |
Attempts to rollback the current transaction
Implemented in DB::MySQL_Connection, and DB::Sqlite3_Connection.
| virtual bool DB::Connection::setTransactionMode | ( | const enum TRANS_MODE | mode | ) | [pure virtual] |
Sets the database transaction mode.
| mode |
| virtual const char* DB::Connection::unixtimeToSql | ( | const | time_t | ) | [pure virtual] |
Returns a database specific representation of the time_t value. This is used by the Query class. The string returned must be freed by the caller.
| time_t |
Implemented in DB::MySQL_Connection, and DB::Sqlite3_Connection.
Referenced by DB::unixtime_impl().
| virtual const char* DB::Connection::version | ( | void | ) | const [pure virtual] |
Returns the DB abstraction module's version number and possibly the version of the underlying database client library used. The returned value should NOT be freed.
Implemented in DB::MySQL_Connection, and DB::Sqlite3_Connection.
1.4.7