znone
2021-02-27 bce9758e32d0c3029a26efb486a342ff05f6df72
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef _QTL_MYSQL_POOL_H_
#define _QTL_MYSQL_POOL_H_
 
#include "qtl_database_pool.hpp"
#include "qtl_postgres.hpp"
 
namespace qtl
{
 
namespace postgres
{
 
class database_pool : public qtl::database_pool<database>
{
public:
    database_pool() : m_port(0) { }
    virtual ~database_pool() { }
    virtual database* new_database() throw() override
    {
        database* db=new database;
        if(!db->open(m_host.data(), m_user.data(), m_password.data(), m_port, m_database.data()))
        {
            delete db;
            db=NULL;
        }
        else
        {
            PQsetClientEncoding(db->handle(), "UTF8");
        }
        return db;
    }
 
protected:
    std::string m_host;
    unsigned short m_port;
    std::string m_database;
    std::string m_user;
    std::string m_password;
};
 
}
 
}
 
#endif //_QTL_MYSQL_POOL_H_