1
모두. 나는 mysql을 연결하는 C++를 사용하려면,하지만 작동하지 않습니다 오류 정보는 다음과 같습니다mysql C++ 커넥터 연결 오류
error LNK2019: unresolved external symbol "__declspec(dllimport) public: char const * __thiscall sql::SQLString::c_str(void)const " ([email protected]@[email protected]@QBEPBDXZ) referenced in function [email protected]@YAXXZ$0
error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sql::SQLString::~SQLString(void)" ([email protected]@@[email protected]) referenced in function "void __cdecl RunConnectMySQL(void)" ([email protected]@YAXXZ)
error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sql::SQLString::SQLString(char const * const)" ([email protected]@@[email protected]@Z) referenced in function "void __cdecl RunConnectMySQL(void)" ([email protected]@YAXXZ)
error LNK2019: unresolved external symbol "__declspec(dllimport) class sql::mysql::MySQL_Driver * __cdecl sql::mysql::get_driver_instance(void)" ([email protected]@[email protected]@[email protected]@XZ) referenced in function "class sql::mysql::MySQL_Driver * __cdecl sql::mysql::get_mysql_driver_instance(void)" ([email protected]@[email protected]@[email protected]@XZ)
그리고 I에 유래에서 같은 질문을 검색해야하지만, 적절한 대답을하지 않았다. 내 코드 :
#include <iostream>
#include <string>
#include <mysql_connection.h>
#include <mysql_driver.h>
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#include <cppconn/prepared_statement.h>
using namespace std;
void RunConnectMySQL()
{
sql::mysql::MySQL_Driver *driver = NULL;
sql::Connection *con = NULL;
Statement *state = NULL;
ResultSet *result = NULL;
try
{
driver = sql::mysql::get_mysql_driver_instance();
con = driver->connect("tcp://127.0.0.1:3306","root","");
state = con->createStatement();
state->execute("use monitor");
result = state->executeQuery("select * from address");
}
catch(sql::SQLException & ex)
{
cout<<ex.what()<<endl;
return;
}
while(result->next())
{
cout<<"source: "<<result->getString("source").c_str()<<endl;
}
state->close();
}
int main()
{
RunConnectMySQL();
system("pause");
return 0;
}
감사합니다.