acl/lib_acl_cpp/include/acl_cpp/db/mysql_pool.hpp
2014-11-19 00:25:21 +08:00

46 lines
1.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include "acl_cpp/acl_cpp_define.hpp"
#include "acl_cpp/db/db_pool.hpp"
namespace acl {
class db_handle;
class ACL_CPP_API mysql_pool : public acl::db_pool
{
public:
/**
* 采用 mysql 数据库时的构造函数
* @param dbaddr {const char*} mysql 服务器地址格式IP:PORT
* 在 UNIX 平台下可以为 UNIX 域套接口
* @param dbname {const char*} 数据库名
* @param dbuser {const char*} 数据库用户
* @param dbpass {const char*} 数据库用户密码
* @param dblimit {int} 数据库连接池的最大连接数限制
* @param dbflags {unsigned long} mysql 标记位
* @param auto_commit {bool} 是否自动提交
* @param conn_timeout {int} 连接数据库超时时间(秒)
* @param rw_timeout {int} 与数据库通信时的IO时间(秒)
*/
mysql_pool(const char* dbaddr, const char* dbname,
const char* dbuser, const char* dbpass,
int dblimit = 64, unsigned long dbflags = 0,
bool auto_commit = true, int conn_timeout = 60,
int rw_timeout = 60);
~mysql_pool();
protected:
// 基类虚函数:创建数据库连接句柄
virtual db_handle* create();
private:
char* dbaddr_; // 数据库监听地址
char* dbname_; // 数据库名
char* dbuser_; // 数据库账号
char* dbpass_; // 数据库账号密码
unsigned long dbflags_;
int conn_timeout_;
int rw_timeout_;
bool auto_commit_;
};
} // namespace acl