tntdb Namespace Reference

Main namespace for tntdb. More...

Classes

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
 This class holds a decimal floating point number. More...
class  Error
 Baseclass for database-errors. More...
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. More...
class  TypeError
 Exception to indicate, that a value couldn't be converted to a requested type. More...
class  SqlError
 Exception, which is a direct result of a sql-statement. More...
class  FieldNotFound
class  LibraryManager
class  NonCopyable
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  Blob
 Binary large objects. More...
class  Connection
 This class holds a connection to a database. 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  Statement
 This class represents a sql-statement. 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.
Connection connectCached (const std::string &url)
 Fetch a connection from a pool or create a new one.
void dropCached (unsigned keep=0)
 Releases unused connections.
void dropCached (const std::string &url, unsigned keep=0)
 Releases unused connections, which match the given url.
void setMaxPoolSize (unsigned max)
 Sets the maximum pool-size of new connectionpools.
unsigned getMaxPoolSize ()
 Returns the current setting for maximum pools size.
std::ostream & operator<< (std::ostream &out, const Decimal &decimal)
 Print this Decimal number.
std::istream & operator>> (std::istream &in, Decimal &decimal)
 Read a Decimal number.

Detailed Description

Main namespace for tntdb.

All code is in this namespace.


Function Documentation

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");
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.

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

Releases unused connections, which match the given url.

Keeps the given number of connections.

void tntdb::dropCached ( unsigned  keep = 0  ) 

Releases unused connections.

Keeps the given number of connections.

unsigned tntdb::getMaxPoolSize (  ) 

Returns the current setting for maximum pools size.

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

std::ostream& tntdb::operator<< ( std::ostream &  out,
const Decimal &  decimal 
)

Print this Decimal number.

If out.precision() != 0, then this decimal number is printed with out.precision() significant digits.

std::istream& tntdb::operator>> ( std::istream &  in,
Decimal &  decimal 
)

Read a Decimal number.

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.

Generated on Tue Apr 6 01:46:47 2010 for tntdb by  doxygen 1.6.3