gpt4 book ai didi

c++ - 我需要 C++ 连接器的示例代码来设置 "mysql_options"

转载 作者:行者123 更新时间:2023-11-28 05:46:19 25 4
gpt4 key购买 nike

如何使用 mySQL C++ 连接器设置超时?我试过这个..但它是编译错误。

error: ‘class sql::Driver’ has no member named ‘mysql_options’
error: ‘MYSQL_READ_DEFAULT_FILE’ was not declared in this scope

代码在这里。

driver = get_driver_instance();
driver->mysql_options(MYSQL_READ_DEFAULT_FILE, "/my.cnf");
con = driver->connect(host, user, password);

我阅读了此页 ( http://dev.mysql.com/doc/refman/5.0/en/mysql-options.html )但是此页面没有 C++“示例”...

我需要帮助!

最佳答案

我自己想办法.. :)效果很好。

    driver = get_driver_instance();

sql::ConnectOptionsMap connection_properties;
connection_properties ["hostName"] = host;
connection_properties ["userName"] = user;
connection_properties ["password"] = password;
connection_properties ["OPT_CONNECT_TIMEOUT"] = 10;
con = driver->connect(connection_properties);

关于c++ - 我需要 C++ 连接器的示例代码来设置 "mysql_options",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36121894/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com