简体   繁体   English

C ++ MySQL驱动程序->连接VS2013

[英]C++ MySQL driver->connect VS2013

I followed this: http://docs.oracle.com/cd/E17952_01/connector-cpp-en/connector-cpp-apps-windows-visual-studio.html to install MySQL and configure it with dynamic linking. 我遵循以下步骤: http : //docs.oracle.com/cd/E17952_01/connector-cpp-en/connector-cpp-apps-windows-visual-studio.html安装MySQL并通过动态链接对其进行配置。

My program compiles but when I debug it and it gets to the line where it does sql->connect it crashes with a few access violations. 我的程序可以编译,但是当我调试它时,它会到达执行sql-> connect的行,并因一些访问冲突而崩溃。

I also get this: 我也得到这个:

+       driver  0x014b3a00 <Information not available, no symbols loaded for mysqlcppconn.dll>  sql::mysql::MySQL_Driver *

Database.cpp 数据库.cpp

#include "Functions.h"
#include "Settings.h"
#include "Database.h"

#define mysqlcppconn_EXPORTS
/* MySQL Connector/C++ specific headers */
#include <mysql_driver.h>
#include <mysql_connection.h>
#include <cppconn/statement.h>
#include <cppconn/prepared_statement.h>
#include <cppconn/resultset.h>
#include <cppconn/metadata.h>
#include <cppconn/resultset_metadata.h>
#include <cppconn/exception.h>
#include <warning.h>

using namespace std;
using namespace sql;

CDatabase::CDatabase(CSettings* settings)
{

    Connection *con;

    sql::mysql::MySQL_Driver *driver;
    driver = sql::mysql::get_mysql_driver_instance();

    con = driver->connect("", "", "");
    con->setSchema("");

    cout << "Connected.";
}

CDatabase::~CDatabase()
{
}

What have I tried? 我尝试了什么?

  • checked the .dll files, both are x86. 检查.dll文件,它们都是x86。
  • googling 谷歌搜索
  • double checked all directories 仔细检查所有目录

My Paths: 我的道路:

C:\Program Files (x86)\MySQL\MySQL Connector C++ 1.1.3\lib\opt
C:\Program Files (x86)\MySQL\MySQL Connector C++ 1.1.3\include

DLLs in the output directory: 输出目录中的DLL:

libmysql.dll
mysqlcppconn.dll

Yeah my bad it was giving a sql error. 是的,我不好,它给出了一个SQL错误。 Didnt realise that I had to try....catch it haha! 没意识到我必须尝试...。抓住它哈哈!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM