sptk2 logo
SPTK Home Page
Public Member Functions | Protected Member Functions | Friends | List of all members
sptk::DatabaseConnectionPool Class Reference

#include <DatabaseConnectionPool.h>

Inheritance diagram for sptk::DatabaseConnectionPool:
sptk::DatabaseConnectionString

Public Member Functions

 DatabaseConnectionPool (const String &connectionString, unsigned maxConnections=100, std::chrono::seconds connectionTimeout=std::chrono::seconds(60))
 
DatabaseConnection getConnection ()
 
std::chrono::seconds connectionTimeout () const
 
- Public Member Functions inherited from sptk::DatabaseConnectionString
 DatabaseConnectionString (const String &connectionString="")
 
 DatabaseConnectionString (const DatabaseConnectionString &cs)=default
 
DatabaseConnectionStringoperator= (const DatabaseConnectionString &cs)=default
 
String toString () const
 
const StringdriverName () const
 
const StringhostName () const
 
const StringuserName () const
 
const Stringpassword () const
 
const StringdatabaseName () const
 
const Stringschema () const
 
uint16_t portNumber () const
 
void userName (const String &user)
 
void password (const String &pass)
 
String parameter (const String &name) const
 
bool empty () const
 

Protected Member Functions

void load ()
 
SPoolDatabaseConnection createConnection ()
 
void releaseConnection (const SPoolDatabaseConnection &connection)
 
- Protected Member Functions inherited from sptk::DatabaseConnectionString
void parse ()
 

Friends

class AutoDatabaseConnection
 

Detailed Description

Database driver loader

Loads and initializes SPTK database driver by request. Already loaded drivers are cached.

Constructor & Destructor Documentation

◆ DatabaseConnectionPool()

sptk::DatabaseConnectionPool::DatabaseConnectionPool ( const String connectionString,
unsigned  maxConnections = 100,
std::chrono::seconds  connectionTimeout = std::chrono::seconds(60) 
)

Constructor

Database connection string is the same for all connections, created with this object.

Parameters
connectionStringDatabase connection string
maxConnectionsMaximum number of connections in the pool

Member Function Documentation

◆ createConnection()

SPoolDatabaseConnection sptk::DatabaseConnectionPool::createConnection ( )
protected

Creates database connection

◆ load()

void sptk::DatabaseConnectionPool::load ( )
protected

Loads database driver

First successfull driver load places driver into driver cache.

◆ releaseConnection()

void sptk::DatabaseConnectionPool::releaseConnection ( const SPoolDatabaseConnection &  connection)
protected

Returns used database connection back to the pool

Parameters
connectionDatabase that is no longer in use and may be returned to the pool

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

Fri Oct 14 2022 09:58:41: SPTK 5.4.1