mirror of
https://github.com/pocoproject/poco.git
synced 2025-06-20 20:27:24 +02: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);
|
void options(mysql_option opt, bool b);
|
||||||
/// Set connection options
|
/// Set connection options
|
||||||
|
|
||||||
|
void options(mysql_option opt, const char* c);
|
||||||
|
/// Set connection options
|
||||||
|
|
||||||
void options(mysql_option opt, unsigned int i);
|
void options(mysql_option opt, unsigned int i);
|
||||||
/// Set connection options
|
/// Set connection options
|
||||||
|
|
||||||
|
@ -81,6 +81,14 @@ void SessionHandle::options(mysql_option opt, bool b)
|
|||||||
throw ConnectionException("mysql_options error", _pHandle);
|
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)
|
void SessionHandle::options(mysql_option opt, unsigned int i)
|
||||||
{
|
{
|
||||||
#if (POCO_MYSQL_VERSION_NUMBER < 0x050108)
|
#if (POCO_MYSQL_VERSION_NUMBER < 0x050108)
|
||||||
|
@ -108,6 +108,7 @@ void SessionImpl::open(const std::string& connect)
|
|||||||
options["compress"] = "";
|
options["compress"] = "";
|
||||||
options["auto-reconnect"] = "";
|
options["auto-reconnect"] = "";
|
||||||
options["secure-auth"] = "";
|
options["secure-auth"] = "";
|
||||||
|
options["character-set"] = "utf8";
|
||||||
|
|
||||||
const std::string& connString = connectionString();
|
const std::string& connString = connectionString();
|
||||||
for (std::string::const_iterator start = connString.begin();;)
|
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())
|
else if (!options["secure-auth"].empty())
|
||||||
throw MySQLException("create session: specify correct secure-auth option (true or false) or skip it");
|
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
|
// Real connect
|
||||||
_handle.connect(options["host"].c_str(),
|
_handle.connect(options["host"].c_str(),
|
||||||
options["user"].c_str(),
|
options["user"].c_str(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user