如何使用mysql的连接器
How to use connector of mysql
我想为mysql数据库使用连接器。我正在关注这个页面
http://dev.mysql.com/tech-resources/articles/mysql-connector-cpp.html
但这似乎很难。还有其他教程吗。请告诉我。
示例代码的相关部分非常简单:
Driver *driver;
Connection *con;
Statement *stmt;
ResultSet *res;
driver = get_driver_instance();
/* create a database connection using the Driver */
con = driver -> connect(url, user, password);
/* alternate syntax using auto_ptr to create the db connection */
//auto_ptr con (driver -> connect(url, user, password));
/* turn off the autocommit */
con -> setAutoCommit(0);
/* select appropriate database schema */
con -> setSchema(database);
从那时起,你只需要像这样查询:
stmt = con -> createStatement();
res = stmt -> executeQuery ("SELECT * FROM City");
相关文章:
- 使用cmake从源代码构建MySQL连接器/C++失败(与以前的声明冲突)
- 使用mysql c++连接器的未定义引用
- MySQL C++连接器链接错误
- C++MySQL连接器没有utf8
- MySQL 连接器/C++.尝试在此过程中停止连接到数据库
- 如何使用连接器 c++ 在 mySQL 表二进制(16) 字段中存储 c++ 字节数组?
- MySQL C++连接器循环
- MySQL c++ 连接器:使用 SetBlob() 在查询中设置多个 blob 数据的正确方法是什么?
- 在 C/C++ 中使用 MySQL 连接器执行插入到表时出错
- 无法在我的ubuntu中正确安装MySQL连接器/c++
- 在 MySQL 连接器C++ API 中使用一个函数调用执行多个查询的正确方法是什么?
- mysql c ++连接器异常:用户"root"@'localhost'的访问被拒绝(使用密码:NO)&&MySQL服务器已消失
- MySQL 连接器 CPP 在 CentOS 6 中未定义的引用
- MySQL C++连接器:添加符号时出错:文件格式无法识别
- MySQL连接器C 结果集被缓冲
- 在 mysql 连接器中对 mysqlx 函数的未定义引用
- 我可以在不知道SQL的情况下使用SQLite或MySQL的C++连接器吗?
- 更新MySQL连接器后,隐式转换停止工作
- 批量插入 Mysql C++连接器
- 使用MySQL C 连接器从C 代码访问MEMSQL