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

int m_id
 The connection Id. More...
 
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 postgis/Connection.h.

Constructor & Destructor Documentation

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

Destructor.

Definition at line 90 of file postgis/Connection.cpp.

References m_pgconn.

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.

Definition at line 96 of file postgis/Connection.cpp.

References m_id, m_pgconn, PostGISNoticeProcessor(), and TE_TR.

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.

Definition at line 61 of file postgis/Connection.cpp.

References m_pgconn, and TE_TR.

Referenced by te::pgis::Transactor::execute(), and te::pgis::ConnectedDataSet::~ConnectedDataSet().

PGconn* te::pgis::Connection::getConn ( ) const
inline

It gets the underlying PGconn object.

Returns
The underlying PGconn object.

Definition at line 97 of file postgis/Connection.h.

Referenced by te::pgis::PreparedQuery::prepare().

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

It gets the associated connection pool.

Returns
The associated connection pool.

Definition at line 107 of file postgis/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.

Definition at line 44 of file postgis/Connection.cpp.

References m_pgconn, and TE_TR.

Referenced by te::pgis::Transactor::query().

Friends And Related Function Documentation

friend class ConnectionPool
friend

Definition at line 135 of file postgis/Connection.h.

Member Data Documentation

bool te::pgis::Connection::m_inuse

Tells if the connection is in use or not.

Definition at line 132 of file postgis/Connection.h.

Referenced by te::pgis::ConnectionPool::getConnection().

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

It marks the last time this connection was used.

Definition at line 133 of file postgis/Connection.h.

Referenced by te::pgis::ConnectionPool::release().

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

The PostgreSQL real connection handle.

Definition at line 131 of file postgis/Connection.h.

Referenced by Connection(), execute(), query(), and ~Connection().

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

The connection pool associated to the connection.

Definition at line 130 of file postgis/Connection.h.


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