A class that implements a connection to a PostgreSQL database. More...
#include <Connection.h>
Public Member Functions | |
void | execute (const std::string &command) |
It executes the given SQL command and throws away the result. More... | |
PGconn * | getConn () const |
It gets the underlying PGconn object. More... | |
ConnectionPool * | getPool () const |
It gets the associated connection pool. More... | |
PGresult * | query (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... | |
PGconn * | m_pgconn |
The PostgreSQL real connection handle. More... | |
ConnectionPool * | m_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 |
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.
Definition at line 68 of file Connection.h.
te::pgis::Connection::~Connection | ( | ) |
Destructor.
Definition at line 80 of file Connection.cpp.
|
private |
Constructor.
pool | The associated connection pool. |
conninfo | A coonection string as undertood by libpq. |
cecoding | The character encoding used by application. |
inuse | A marker that tells if the connection is in use or not. |
Definition at line 86 of file Connection.cpp.
References m_pgconn, PostGISNoticeProcessor(), and TE_TR.
void te::pgis::Connection::execute | ( | const std::string & | command | ) |
It executes the given SQL command and throws away the result.
command | Any SQL command. |
Exception | It throws an exception if the query execution fails. |
Definition at line 61 of file Connection.cpp.
References TE_TR.
|
inline |
It gets the underlying PGconn object.
Definition at line 97 of file Connection.h.
Referenced by te::pgis::PreparedQuery::PreparedQuery().
|
inline |
It gets 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.
query | A SQL Select command. |
Exception | It throws an exception if the query execution fails. |
Definition at line 44 of file Connection.cpp.
|
friend |
Definition at line 134 of file Connection.h.
bool te::pgis::Connection::m_inuse |
Tells if the connection is in use or not.
Definition at line 131 of file Connection.h.
Referenced by te::pgis::ConnectionPool::release().
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.
Referenced by te::pgis::ConnectionPool::release().
PGconn* te::pgis::Connection::m_pgconn |
The PostgreSQL real connection handle.
Definition at line 130 of file Connection.h.
Referenced by Connection(), and query().
ConnectionPool* te::pgis::Connection::m_pool |
The connection pool associated to the connection.
Definition at line 129 of file Connection.h.