this class represents connection to database More...
#include <cppdb/backend.h>
Public Member Functions | |
connection (connection_info const &info) | |
virtual void | begin ()=0 |
virtual void | commit ()=0 |
virtual void | rollback ()=0 |
virtual statement * | prepare_statement (std::string const &q)=0 |
virtual statement * | create_statement (std::string const &q)=0 |
virtual std::string | escape (std::string const &)=0 |
virtual std::string | escape (char const *s)=0 |
virtual std::string | escape (char const *b, char const *e)=0 |
virtual std::string | driver ()=0 |
virtual std::string | engine ()=0 |
void | clear_cache () |
bool | once_called () const |
void | once_called (bool v) |
connection_specific_data * | connection_specific_get (std::type_info const &type) const |
connection_specific_data * | connection_specific_release (std::type_info const &type) |
void | connection_specific_reset (std::type_info const &type, connection_specific_data *p=0) |
bool | recyclable () |
void | recyclable (bool value) |
this class represents connection to database
cppdb::backend::connection::connection | ( | connection_info const & | info | ) |
Create a new object. Connection information info is required
virtual void cppdb::backend::connection::begin | ( | ) | [pure virtual] |
Start new isolated transaction. Would not be called withing other transaction on current connection.
Clear statements cache
virtual void cppdb::backend::connection::commit | ( | ) | [pure virtual] |
Commit the transaction, you may assume that is called after begin() was called.
connection_specific_data* cppdb::backend::connection::connection_specific_get | ( | std::type_info const & | type | ) | const |
Get connection specific data pointer of the type type , default 0.
The ownership is not changed
connection_specific_data* cppdb::backend::connection::connection_specific_release | ( | std::type_info const & | type | ) |
Release ownership connection specific data pointer of the type type
void cppdb::backend::connection::connection_specific_reset | ( | std::type_info const & | type, |
connection_specific_data * | p = 0 |
||
) |
Remove old connection specific data and set new one for a given type type , the ownership on p is transferred to connection.
virtual statement* cppdb::backend::connection::create_statement | ( | std::string const & | q | ) | [pure virtual] |
Create a (unprepared) statement q. May throw if preparation had failed. Should never return null value.
virtual std::string cppdb::backend::connection::driver | ( | ) | [pure virtual] |
Get the name of the driver, for example sqlite3, odbc
virtual std::string cppdb::backend::connection::engine | ( | ) | [pure virtual] |
Get the name of the SQL Server, for example sqlite3, mssql, oracle, differs from driver() when the backend supports multiple databases like odbc backend.
virtual std::string cppdb::backend::connection::escape | ( | std::string const & | ) | [pure virtual] |
Escape a string for inclusion in SQL query. May throw not_supported_by_backend() if not supported by backend.
virtual std::string cppdb::backend::connection::escape | ( | char const * | s | ) | [pure virtual] |
Escape a string for inclusion in SQL query. May throw not_supported_by_backend() if not supported by backend.
virtual std::string cppdb::backend::connection::escape | ( | char const * | b, |
char const * | e | ||
) | [pure virtual] |
Escape a string for inclusion in SQL query. May throw not_supported_by_backend() if not supported by backend.
bool cppdb::backend::connection::once_called | ( | ) | const |
Check if session specific preparations are done
For new connections always false
void cppdb::backend::connection::once_called | ( | bool | v | ) |
Set once status - true if called flase
virtual statement* cppdb::backend::connection::prepare_statement | ( | std::string const & | q | ) | [pure virtual] |
Create a prepared statement q. May throw if preparation had failed. Should never return null value.
Check if this back-end can be recycled for reuse in a pool.
If an exception is thrown during operation on DB this flag is reset to false by the front-end classes result, statement, session.
Default is true
void cppdb::backend::connection::recyclable | ( | bool | value | ) |
Set recyclable state of the session. If some problem occurs on connection that prevents its reuse it should be called with false parameter.
virtual void cppdb::backend::connection::rollback | ( | ) | [pure virtual] |
Rollback the transaction. MUST never throw!!!