关于MySQL Connector/C++那点事儿
如果从官方直接下载的库使用时遇到类似如下的问题:

原因是官方提供的库文件版本与需要的库版本不匹配,提供的debug版本使用的是MT版本,在debug模式下会出现内存错误,导致crash。
TestC.exe中的...dll有未经处理的异常:读取位置时发生访问冲突。
那么可能需要自己手动编译源码(参考编译MySQL Connector/C++的资料)啦:
重新设置包含目录和库目录(实际中请把想要的头文件和库文件最好放到自己的工程目录里的第三方库或头文件如Libs之类的目录下,保证工程的可一致性,而不是像这里这样F:\Tools\....这样):

重新编译运行:

#include <stdlib.h>
#include <iostream> #include <driver/mysql_connection.h>
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h> using namespace std; int main(void)
{
cout << "Running 'SELECT 'Hello World!' AS _message'..." << endl; try
{
sql::Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
sql::ResultSet *res; /* 连接mysql服务器 */
driver = get_driver_instance();
con = driver->connect("tcp://127.0.0.1:3307", "root", "*****");
con->setSchema("test"); stmt = con->createStatement();
res = stmt->executeQuery("SELECT 'Hello World!' AS _message");
while (res->next()) {
//通过列别名访问
cout << res->getString("_message") << endl;
//通过列偏移
cout << res->getString(1) << endl;
} delete res;
delete stmt;
delete con;
}
catch (sql::SQLException &e)
{
cout << "# ERR: SQLException in " << __FILE__;
cout << "(" << __FUNCTION__ << ") on line " << __LINE__ << endl;
cout << "# ERR: " << e.what();
cout << " (MySQL error code: " << e.getErrorCode();
cout << ", SQLState: " << e.getSQLState() << " )" << endl;
}
cin.get();
return EXIT_SUCCESS;
}
MySQL Connector/C++文档:
http://dev.mysql.com/doc/refman/5.6/en/connector-cpp.html
关于MySQL Connector/C++那点事儿的更多相关文章
- 第11月第20天 sqlite3_open xcode mysql connector
1. sqlite3_open 死锁 * thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP frame ...
- 创建ASP.NET Core MVC应用程序(2)-利用MySQL Connector NET连接到MySQL
创建ASP.NET Core MVC应用程序(2)-利用MySQL Connector NET连接到MySQL 用惯.NET的研发人员都习惯性地使用SQLServer作为数据库.然而.NET Core ...
- vc++2013中使用MySQL connector/C++ 1.1.4静态链接报错
包含头文件 #include <mysql_connection.h> #include <mysql_driver.h> #include <cppconn/state ...
- Using MySQL Connector .NET 6.6.4 with Entity Framework 5
I had been waiting for the latest MySQL connector for .NET to come out so I can move on to the new a ...
- [转]MySQL Connector/C++(一)
http://www.cnblogs.com/dvwei/archive/2013/04/18/3029464.html#undefined#undefined MySQL Connector/C++ ...
- mysql.connector操作mysql的blob值
This tutorial shows you how to work with MySQL BLOB data in Python, with examples of updating and re ...
- Ubuntu & MacOS安装Mysql & connector
Ubuntu & MacOS安装Mysql & connector 1. 安装MySql sudo apt-get install mysql-server apt-get insta ...
- Snippet: Fetching results after calling stored procedures using MySQL Connector/Python
https://geert.vanderkelen.org/2014/results-after-procedure-call/ Problem Using MySQL Connector/Pytho ...
- MySQL Connector/J 6.x jdbc.properties 配置, mysql-connector-java-6.0.4.jar 异常
今天学习SSM框架整合,完成Spring和mybatis这两大框架的整合做测试时候出来很多问题,主要来自于配置文件. 我这里重点说一下Mysql数据驱动配置. 配置pom.xml时候去网站 MySQL ...
随机推荐
- 每天一个Linux命令(2):cd
转自:http://www.cnblogs.com/peida/archive/2012/10/24/2736501.html Linux cd命令可以说是Linux中最基本的命令语句,其他的命令语句 ...
- 关于关闭Eclipse的控制台自动跳出
参考文章: http://my.oschina.net/mn1127/blog/161093 Eclipse的控制台console有时候经常的跳出来,非常的烦人! 尤其是在调试期间跳出,以下是分享一下 ...
- Linux 文件/文件夹操作命令
1 cd命令 命令格式:cd [目录名] (cd和目录之间使用空格隔开) cd 进入用户主目录: cd ~ 进入用户主目录: cd - 返回进入此目录之前所在的目录: cd ...
- T-SQL利用Row_Number函数实现分页
SQL: CREATE PROCEDURE PagingViewTest ( @currentPageIndex INT, --页序号 @pageSize INT, --页大小 @pageCount ...
- 利用jQuery实现选项卡
/*Tab 选项卡 标签*/ $(function(){ var $div_li =$("div.tab_menu ul li"); $div_li.click(function( ...
- SignalR 2.0 系列:SignalR的服务器广播
英文渣水平,大伙凑合着看吧…… 这是微软官方SignalR 2.0教程Getting Started with ASP.NET SignalR 2.0系列的翻译,这里是第八篇:SignalR的服务器广 ...
- Viewpager+Fragment出现空白页面的问题
写了三个Fragment,一次点击跳转显示正常,如果从第一个直接跳转到第三个,第三个页面会出现空白界面. 问题找到了:原来动态获取数据页面数据不显示,页面显示空白,就是onCreateView每次都调 ...
- ADB 无法启动
今天在做项目时候,突然无法启动,进入CMD命令启动adb 提示: adb server is out of date. killing... ADB server didn't ACK * faile ...
- PHP学习笔记 - 进阶篇(8)
PHP学习笔记 - 进阶篇(8) 日期与时间 取得当前的Unix时间戳 UNIX 时间戳(英文叫做:timestamp)是 PHP 中关于时间与日期的一个很重要的概念,它表示从 1970年1月1日 0 ...
- MLlearning(2)——simHash算法
这篇文章主要讲simHash算法.这是一种LSH(Locality-Sensitive Hashing,局部敏感哈希)的简单实现.它是广泛用于数据去重的算法,可以用于相似网站.图片的检索.而且当两个样 ...