Click here to Skip to main content
15,881,764 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
  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://dev.mysql.com/doc/dev/connector-cpp/devapi_ref.html</a>
   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:

C++
void test_XdevCPlus_demo()
{
    std::string usr = "root";
    std::string pwd = "1030";
    // Connect to MySQL Server on a network machine
    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
C++
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?
Posted
Updated 6-Apr-19 15:07pm
v3
Comments
Michael Haephrati 18-May-19 10:15am    
Did you check the guidelines for connection strings? https://www.connectionstrings.com/mysql/
Michael Haephrati 10-Jul-19 9:52am    
Try this solution from : https://stackoverflow.com/questions/13890021/mysql-workbench-error-opening-eer
Just close and reopen the application.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900