te::pgis::Connection Class Reference

A class that implements a connection to a PostgreSQL database. More...

#include <Connection.h>

Inheritance diagram for te::pgis::Connection:

Public Member Functions

void execute (const std::string &command)
 It executes the given SQL command and throws away the result. More...
 
PGconngetConn () const
 It gets the underlying PGconn object. More...
 
ConnectionPoolgetPool () const
 It gets the associated connection pool. More...
 
PGresultquery (const std::string &query)
 It queries the database. More...
 
 ~Connection ()
 Destructor. More...
 

Public Attributes

bool m_inuse
 Tells if the connection is in use or not. More...
 
boost::posix_time::ptime m_lastuse
 It marks the last time this connection was used. More...
 
PGconnm_pgconn
 The PostgreSQL real connection handle. More...
 
ConnectionPoolm_pool
 The connection pool associated to the connection. More...
 

Private Member Functions

 Connection (ConnectionPool *pool, const std::string &conninfo, const std::string &cencoding, bool inuse=false)
 Constructor. More...
 

Friends

class ConnectionPool
 

Detailed Description

A class that implements a connection to a PostgreSQL database.

This class models a physical connection to a PostgreSQL data source. It is designed to work with the connection pool.

See also
ConnectionPool

Definition at line 68 of file Connection.h.

Constructor & Destructor Documentation

te::pgis::Connection::~Connection ( )

Destructor.

te::pgis::Connection::Connection ( ConnectionPool pool,
const std::string &  conninfo,
const std::string &  cencoding,
bool  inuse = false 
)
private

Constructor.

Parameters
poolThe associated connection pool.
conninfoA coonection string as undertood by libpq.
cecodingThe character encoding used by application.
inuseA marker that tells if the connection is in use or not.

Member Function Documentation

void te::pgis::Connection::execute ( const std::string &  command)

It executes the given SQL command and throws away the result.

Parameters
commandAny SQL command.
Exceptions
ExceptionIt throws an exception if the query execution fails.
PGconn* te::pgis::Connection::getConn ( ) const
inline

It gets the underlying PGconn object.

Returns
The underlying PGconn object.

Definition at line 97 of file Connection.h.

ConnectionPool* te::pgis::Connection::getPool ( ) const
inline

It gets the associated connection pool.

Returns
The associated connection pool.

Definition at line 107 of file Connection.h.

PGresult* te::pgis::Connection::query ( const std::string &  query)

It queries the database.

Parameters
queryA SQL Select command.
Returns
A resultset. The caller of this method will take its ownership.
Exceptions
ExceptionIt throws an exception if the query execution fails.

Friends And Related Function Documentation

friend class ConnectionPool
friend

Definition at line 134 of file Connection.h.

Member Data Documentation

bool te::pgis::Connection::m_inuse

Tells if the connection is in use or not.

Definition at line 131 of file Connection.h.

boost::posix_time::ptime te::pgis::Connection::m_lastuse

It marks the last time this connection was used.

Definition at line 132 of file Connection.h.

PGconn* te::pgis::Connection::m_pgconn

The PostgreSQL real connection handle.

Definition at line 130 of file Connection.h.

ConnectionPool* te::pgis::Connection::m_pool

The connection pool associated to the connection.

Definition at line 129 of file Connection.h.


The documentation for this class was generated from the following file: