| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions
TeConnectionPool Class Reference

`#include <TeConnectionPool.h>`

List of all members.

## Public Member Functions

bool | initialize (const std::string &user, const std::string &password, const std::string &host, const std::string &dbName, const std::string &dbmsName, const int &portNumber)
| Intializes the pool of connections given a set of parameters.
TeConnection * | getConnection ()
| Gets a free connection that can be used for a TeDatabase instance.
void | releaseConnection (TeConnection *conn)
| Releases the given connection.
Constructor
Initilizer methods.
| TeConnectionPool (const unsigned int &maxConnections, const unsigned int &maxIdle=0, const clock_t &maxWait=10000)
| Constructor.
| ~TeConnectionPool ()
| Destructor.
Access method.
Method to access the pool attrbiutes.
void | setTimeOut (const clock_t t)
| Sets the time limit to wait for a connection (in milliseconds).

## Constructor & Destructor Documentation

TeConnectionPool::TeConnectionPool | ( | const unsigned int & | maxConnections,
|  | const unsigned int & | maxIdle = `0`,
|  | const clock_t & | maxWait = `10000`
| ) |  |

Constructor.

Parameters:

  nConns | The number of connections that will be controlled by the pool.
  timeOut | Time limit to wait for a connection (in milliseconds).

TeConnectionPool::~TeConnectionPool | ( |  | ) |

Destructor.

## Member Function Documentation

TeConnection * TeConnectionPool::getConnection | ( |  | ) |

Gets a free connection that can be used for a TeDatabase instance.

Note:
  This method is thread-safe.
  The caller of this method will NOT take the ownership of the returned pointer.
  Case not exists a free connection, the caller will wait on a queue for one, respecting the time out.
  Case time out exceeds a NULL pointer will be returned.
  The connection should be repassed again to the pool after used using the method releaseConnection. Example: { TeConnection* c = pool->getConnection(); db->setConnection(c); // TeDatabase instance do something... pool->releaseConnection(c); }

bool TeConnectionPool::initialize | ( | const std::string & | user,
|  | const std::string & | password,
|  | const std::string & | host,
|  | const std::string & | dbName,
|  | const std::string & | dbmsName,
|  | const int & | portNumber
| ) |  |

Intializes the pool of connections given a set of parameters.

Parameters:

  user | The database user.
  password | The user password.
  host | The database host.
  dbName | The database name.
  dbmsName | The database manager system name (i.e. PostgreSQL, Access).
  portNumber | The database port.

void TeConnectionPool::releaseConnection | ( | TeConnection * | conn | ) |

Releases the given connection.

Note:
  This method is thread-safe.
  The given connection will be deleted.

void TeConnectionPool::setTimeOut | ( | const clock_t | t | ) |

Sets the time limit to wait for a connection (in milliseconds).

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

- E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/kernel/TeConnectionPool.h
- E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/kernel/TeConnectionPool.cpp

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines