// // Created by dongl on 23-4-8. // #include "ConnectionPool.h" #include mysqlpp::Connection *ConnectionPool::create() { return new mysqlpp::Connection( db_.empty() ? nullptr : db_.c_str(), server_.empty() ? nullptr : server_.c_str(), user_.empty() ? nullptr : user_.c_str(), password_.empty() ? "" : password_.c_str()); } void ConnectionPool::destroy(mysqlpp::Connection *connection) { delete connection; } unsigned int ConnectionPool::max_idle_time() { return 30; } ConnectionPool::ConnectionPool(std::string server, std::string db, std::string user, std::string password) : server_(std::move(server)), db_(std::move(db)), user_(std::move(user)), password_(std::move(password)) {} ConnectionPool::~ConnectionPool() { clear(); }