I installed Visual Studio 2017 linked to mysql-connector-c++-8.0.15-winx64. I created a Windows Console application with the exact source code from
<a href="http://dev.mysql.com/doc/dev/connector-cpp/devapi_ref.html">http:
I'm using MySQL Connector/C++ 8.0.15 to connect MySQL Database ,When I run the example in Visual Studio 2017,it failed with an error "string too long".
<pre>
<pre>
The C++ code is just as below:
void test_XdevCPlus_demo()
{
std::string usr = "root";
std::string pwd = "1030";
try
{
Session mySession(
SessionOption::USER, usr,
SessionOption::PWD, pwd,
SessionOption::HOST, "localhost",
SessionOption::PORT, 33060,
SessionOption::DB, "test",
SessionOption::SSL_MODE, SSLMode::DISABLED
);
Schema myDb = mySession.getSchema("test");
}
catch (mysqlx::Error::exception& e)
{
std::cout << e.what() << std::endl;
}
}
What I have tried:
When I run the example, I got Creating session on localhost, port 33060 ... STD EXCEPTION: string too long The exception happens at Impl::from_utf8(*this, utf8) where utf8="root". // TODO: make utf8 conversions explicit
string(const char *other)
{
if (!other)
return;
std::string utf8(other);
Impl::from_utf8(*this, utf8);
}
catch (std::exception &ex)
{
cout << "STD EXCEPTION: " << ex.what() << endl;
return 1;
}
Would you please help?