tntdb Namespace Reference

Main namespace for tntdb. More...

## Classes

class | Blob
| Binary large objects. More...
class | BlobIStream
| istream for reading from a tntdb::Blob More...
class | BlobStreamBuf
| streambuf for reading from a tntdb::Blob More...
class | Connection
| This class holds a connection to a database. More...
class | ConnectionPool
class | ConnectionPools
class | Date
| This class holds a date. More...
class | Datetime
| This class holds a date and a time. More...
class | Decimal
class | Error
| Baseclass for database-errors. More...
class | FieldNotFound
class | Hostvar
| Helper class to hold a tntdb::Statement and a column name. More...
class | LibraryManager
class | NotFound
| Thrown, if selectRow or selectValue does not fetch any data. More...
class | NullValue
| This exception is thrown, when a value is extracted with Value::get...(), but the value is null. More...
class | Result
| The class holds a resultset of a query. More...
class | Row
| Row represents a row, which is fetched from the database. More...
class | RowReader
| A RowReader is a class which helps reading multiple columns from a row. More...
class | SqlBuilder
class | SqlError
| Exception, which is a direct result of a sql-statement. More...
class | Statement
| This class represents a sql-statement. More...
class | StmtEvent
class | StmtParser
class | Time
| This class holds a time. More...
class | Transaction
| The class Transaction monitors the state of a transaction on a database-conection. More...
class | TypeError
| Exception to indicate, that a value couldn't be converted to a requested type. More...
class | Value
| The class Value represents a value, which is fetched from the database. More...

## Functions

Connection | connect (const std::string &url)
| Establish a connection to a database. More...
Connection | connectCached (const std::string &url)
| Fetch a connection from a pool or create a new one. More...
void | dropCached (unsigned keep=0)
| Releases unused connections. More...
void | dropCached (const std::string &url, unsigned keep=0)
| Releases unused connections, which match the given url. More...
void | setMaxPoolSize (unsigned max)
| Sets the maximum pool-size of new connectionpools. More...
unsigned | getMaxPoolSize ()
| Returns the current setting for maximum pools size. More...
std::istream & | operator>> (std::istream &in, Decimal &dec)
std::ostream & | operator<< (std::ostream &out, const Decimal &dec)
void | operator<< (Hostvar &hostvar, bool data)
| Set operators for host variables. More...
void | operator<< (Hostvar &hostvar, int data)
void | operator<< (Hostvar &hostvar, long data)
void | operator<< (Hostvar &hostvar, unsigned data)
void | operator<< (Hostvar &hostvar, unsigned long data)
void | operator<< (Hostvar &hostvar, int32_t data)
void | operator<< (Hostvar &hostvar, uint32_t data)
void | operator<< (Hostvar &hostvar, int64_t data)
void | operator<< (Hostvar &hostvar, uint64_t data)
void | operator<< (Hostvar &hostvar, const Decimal &data)
void | operator<< (Hostvar &hostvar, float data)
void | operator<< (Hostvar &hostvar, double data)
void | operator<< (Hostvar &hostvar, char data)
void | operator<< (Hostvar &hostvar, const std::string &data)
void | operator<< (Hostvar &hostvar, const char *data)
void | operator<< (Hostvar &hostvar, const cxxtools::String &data)
void | operator<< (Hostvar &hostvar, const Blob &data)
void | operator<< (Hostvar &hostvar, const Date &data)
void | operator<< (Hostvar &hostvar, const Time &data)
void | operator<< (Hostvar &hostvar, const Datetime &data)
template<typename T >
void | operator<< (Hostvar &hostvar, const std::vector< T > &data)
template<typename T >
void | operator<< (Hostvar &hostvar, const std::list< T > &data)
template<typename T >
void | operator<< (Hostvar &hostvar, const std::deque< T > &data)
template<typename T >
void | operator<< (Hostvar &hostvar, const std::set< T > &data)
bool | operator>> (const Value &value, bool &out)
| Extraction operators for standard types. More...
bool | operator>> (const Value &value, short &out)
bool | operator>> (const Value &value, int &out)
bool | operator>> (const Value &value, long &out)
bool | operator>> (const Value &value, unsigned short &out)
bool | operator>> (const Value &value, unsigned &out)
bool | operator>> (const Value &value, unsigned long &out)
bool | operator>> (const Value &value, int32_t &out)
bool | operator>> (const Value &value, uint32_t &out)
bool | operator>> (const Value &value, int64_t &out)
bool | operator>> (const Value &value, uint64_t &out)
bool | operator>> (const Value &value, Decimal &out)
bool | operator>> (const Value &value, float &out)
bool | operator>> (const Value &value, double &out)
bool | operator>> (const Value &value, char &out)
bool | operator>> (const Value &value, std::string &out)
bool | operator>> (const Value &value, cxxtools::String &out)
bool | operator>> (const Value &value, Blob &out)
bool | operator>> (const Value &value, Date &out)
bool | operator>> (const Value &value, Time &out)
bool | operator>> (const Value &value, Datetime &out)

## Detailed Description

Main namespace for tntdb.

All code is in this namespace.

## Function Documentation

## connect()

Connection tntdb::connect | ( | const std::string & | url | ) |

Establish a connection to a database.

The url is prefixed with a drivername followed by a colon and a driver- specific part. If the connection can't be established, a exception of type tntdb::Error or derived is thrown.

Examples:

tntdb::Connection sqConn = tntdb::connect("sqlite:mydatabase.db");
tntdb::Connection pgConn = tntdb::connect("postgresql:dbname=DS2 user=web passwd=web");
tntdb::Connection myConn = tntdb::connect("mysql:db=DS2;user=web;passwd=web");
tntdb::Connection orConn = tntdb::connect("oracle:XE;user=hr;passwd=hr");

## connectCached()

Connection tntdb::connectCached | ( | const std::string & | url | ) |

Fetch a connection from a pool or create a new one.

A static pool of connections is kept in memory. The function looks in this pool, if there is a connection, which matches the url. If found the connection is removed from the pool and returned. When the returned connection-object is destroyed (and all copies of it), the actual connection is put back into the pool.

When there is no connections in the pool, which match the url, a new connection is established.

## dropCached() [1/2]

void tntdb::dropCached | ( | const std::string & | url,
|  | unsigned | keep = `0`
| ) |  |

Releases unused connections, which match the given url.

Keeps the given number of connections.

## dropCached() [2/2]

void tntdb::dropCached | ( | unsigned | keep = `0` | ) |

Releases unused connections.

Keeps the given number of connections.

## getMaxPoolSize()

unsigned tntdb::getMaxPoolSize | ( |  | ) |

Returns the current setting for maximum pools size.

The maximum pools size is used, when a new pool is created

## operator<<()

void tntdb::operator<< | ( | Hostvar & | hostvar,
|  | bool | data
| ) |  |

inline

Set operators for host variables.

## operator>>()

bool tntdb::operator>> | ( | const Value & | value,
|  | bool & | out
| ) |  |

inline

Extraction operators for standard types.

## setMaxPoolSize()

void tntdb::setMaxPoolSize | ( | unsigned | max | ) |

Sets the maximum pool-size of new connectionpools.

When the maximum number of connections to a specific url is reached, connectCached blocks until a connection is available. The setting do not affect pools with active connections. You should release all connections and drop clear the pool to your url with dropCached(url), which recreates the pool.

tntdb::Connection
This class holds a connection to a database.
Definition: connection.h:66
tntdb::connect
Connection connect(const std::string &url)
Establish a connection to a database.