mirror of
https://github.com/pocoproject/poco.git
synced 2025-03-22 23:22:20 +01:00
Add MySQL charset configuration support
This commit is contained in:
parent
8a6768e6a6
commit
1324366974
@ -68,6 +68,9 @@ public:
|
||||
void options(mysql_option opt, bool b);
|
||||
/// Set connection options
|
||||
|
||||
void options(mysql_option opt, const char* c);
|
||||
/// Set connection options
|
||||
|
||||
void options(mysql_option opt, unsigned int i);
|
||||
/// Set connection options
|
||||
|
||||
|
@ -81,6 +81,14 @@ void SessionHandle::options(mysql_option opt, bool b)
|
||||
throw ConnectionException("mysql_options error", _pHandle);
|
||||
}
|
||||
|
||||
|
||||
void SessionHandle::options(mysql_option opt, const char* c)
|
||||
{
|
||||
if (mysql_options(_pHandle, opt, c) != 0)
|
||||
throw ConnectionException("mysql_options error", _pHandle);
|
||||
}
|
||||
|
||||
|
||||
void SessionHandle::options(mysql_option opt, unsigned int i)
|
||||
{
|
||||
#if (POCO_MYSQL_VERSION_NUMBER < 0x050108)
|
||||
|
@ -108,6 +108,7 @@ void SessionImpl::open(const std::string& connect)
|
||||
options["compress"] = "";
|
||||
options["auto-reconnect"] = "";
|
||||
options["secure-auth"] = "";
|
||||
options["character-set"] = "utf8";
|
||||
|
||||
const std::string& connString = connectionString();
|
||||
for (std::string::const_iterator start = connString.begin();;)
|
||||
@ -157,6 +158,9 @@ void SessionImpl::open(const std::string& connect)
|
||||
else if (!options["secure-auth"].empty())
|
||||
throw MySQLException("create session: specify correct secure-auth option (true or false) or skip it");
|
||||
|
||||
if (!options["character-set"].empty())
|
||||
_handle.options(MYSQL_SET_CHARSET_NAME, options["character-set"].c_str());
|
||||
|
||||
// Real connect
|
||||
_handle.connect(options["host"].c_str(),
|
||||
options["user"].c_str(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user