c++ - 如何使用 xdevapi 通过 C++ 代码登录 MySQL?
问题描述
我正在尝试使用构建连接器 c++ 通过 C++ 代码登录 MySQL,这是我删除密码的代码:
std::string url = "mysqlx://localhost:3306/license_db?user=licuser&password=**********";
会话我的会话(网址);
mySession.sql("使用 license_db").execute();
auto result = mySession.sql("SELECT * FROM product").execute();
行 row1 = result.fetchOne();
该代码导致“Session mySession(url);”出现异常 行和异常说“分配错误”。
有人可以帮忙吗?
解决方案
X DevAPI的 URI 通常是mysqlx://user:password@host:3306/schema,适用于 JS、PHP 和 Python。
在https://dev.mysql.com/doc/x-devapi-userguide/en/database-connection-example.html有一个用于 C++的示例
var mySession = MySQLX.GetSession("server=localhost;port=33060;user=user;password=password;");
推荐阅读
- spring-boot - 动态更改 Spring Data 查询字符串
- php - Laravel 7:无法在全新安装时运行开发
- sql - JPA PostreSQL 多对多关系选择并按关系数量排序
- maven - 我对 springboot-web-embed-tomcat 有依赖问题,它在日志中给了我以下错误
- .net - .NET Core 中的 TallComponents
- python - 迭代地组合字符串并删除第一个字符串
- unity3d - 在赛车游戏中吸收碰撞时的冲击力
- javascript - VueJS在单个文件中选择组件
- typescript - 有没有办法在 Firebase 中创建经过身份验证的用户 ID 之前更改它们。它们由 facebook 提供商创建
- flutter - 使用 Kotlin 开发 Flutter 插件与使用 Java 编写的插件有什么不同吗?