Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL C++/Connector setClientOption to support multiple statements

I have a MySQL client written with C++. I want to enable the MultipleStatement option as described here, but for the C++ of course:

http://dev.mysql.com/doc/refman/5.0/en/c-api-multiple-queries.html

It is impossible to find this on google. Also it is impossible to find any documentation for the C++/Connector. This is pretty frustrating.

If anyone knows any solution for my problem or any documentation page that would be very very helpful.

Thank you

like image 314
Poniros Avatar asked Dec 06 '13 09:12

Poniros


People also ask

How do I run multiple SQL statements in MySQL?

MySQL also supports the execution of a string containing multiple statements separated by semicolon ( ; ) characters. This capability is enabled by special options that are specified either when you connect to the server with mysql_real_connect() or after connecting by calling mysql_set_server_option() .

What is the connector C++ in MySQL?

MySQL Connector/C++ is a library for applications written in C or C++ that communicate with MySQL database servers. Version 8.0 of Connector/C++ implements three different APIs which can be used by applications: The new X DevAPI for applications written in C++.


1 Answers

This worked for me:

sql::ConnectOptionsMap connection_properties;

connection_properties["hostName"]=sql::SQLString("localhost");
connection_properties["userName"]=sql::SQLString("username");
connection_properties["password"]=sql::SQLString("password");
connection_properties["CLIENT_MULTI_STATEMENTS"]=(true);

sql::Driver * driver = get_driver_instance();
std::unique_ptr<sql::Connection> con(driver->connect(connection_properties));

Regards,

like image 58
lenguador Avatar answered Oct 04 '22 21:10

lenguador