Bug #110528 CDK Error: Failed string conversion
Submitted: 28 Mar 2023 8:50 Modified: 15 Jun 2023 13:02
Reporter: 寅雨 何 Email Updates:
Status: No Feedback Impact on me:
None 
Category:Connector / C++ Severity:S3 (Non-critical)
Version:8.0.30 OS:Windows (windows 10)
Assigned to: MySQL Verification Team CPU Architecture:Any
Tags: database connection can not

[28 Mar 2023 8:50] 寅雨 何
Description:
code like this:
_____________________________________________________________________________
#include<mysqlx/xdevapi.h>
#include<iostream>

using namespace mysqlx;

int main() {
	try
	{
		Session sess("localhost", 33060, "root", "123456");
		std::cout << "success" << std::endl;
	}
	catch (const std::exception& e)
	{
		std::cout << e.what() << std::endl;
	}
	return 0;
}
_____________________________________________________________________________

I recently installed the MySQL connector 8.0 for C++. I've been trying to use the tutorial codes to run a basic example of a connection (create instance of the 'Session' class), but I keep getting this error when providing the constructor parameters for the class.

While the documentation states that only const& strings are used in the constructor, the Connector actually has an own implementation of a string wrapper (mysqlx::abi2::r0::string), which apparently is supposed to convert strings of chars to whatever format the API uses. However, every time I try to construct one of these objects, a 'fromUTF8' function is triggered and some sort of error occurs (hence the title). I can't check the implementation of the function since it's inside a DLL.

Does anyone know how to fix this? Or at least what causes it? I already tried initializing this wrapper with other supported explicit conversion options that the library offers (std::u16string), but then I get a 'bad array length' exeception.

How to repeat:
just create connection.
[15 May 2023 13:02] MySQL Verification Team
Hello,

Thank you for the bug report.
Could you please provide the error message along with exact steps to reproduce this issue at our end?

Regards,
Ashwini Patil
[16 Jun 2023 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".