C++ SQL 连接"get_driver_instance(); is undefined "错误
c++ sql connection "get_driver_instance(); is undefined " error
mycode是;
#include<iostream>
using namespace std;
#include <string>
#include "mysql_connection.h"
#include <stdlib.h>
#include <iomanip>
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#include <cppconn/prepared_statement.h>
int main(){
cout<<"sadullah";
string database = "sch1667138";
string ipAdress = "144.122.71.165";
string password = "???";
string userName = "???";
sql::Driver *driver;
sql::Connection *con;
try {
driver =get_driver_instance();
con = driver->connect("tcp://" + ipAdress + ":3306", userName,
password);
con->setSchema("sch1667138");
cout << "successfully connected to db...." << endl;
} catch (sql::SQLException &e) {
cout << e.what() <<endl;
}
return 0;
}
运行代码时,我会输入消息"参考undefined get_driver_instance();"我该怎么办
我解决了问题。原因是我在Ubuntu上工作,我应该用代码从终端运行它。g -o sado 1667138.cpp -lmysqlcppconn sadu是execute文件的名称,-lmysqlcppconn正在将mysql库添加到cpp
相关文章:
- C++错误:"error: int aaa::bbb is protected within this context"
- 使用 cmake 的 Linux 终端上的"Conversion to non-scalar type is requested"错误
- 结构中的错误"Incomplete type is not allowed"
- 错误说"camera is undefined",但我确实定义了它
- Atom gpp编译器给出"'C:UsersadminUser' is not recognized as an internal or..."错误
- 当我编译XG-Bosst时,出现错误"error: 'Split' is not a member of 'xgboost::common' ……"
- 从 MSVC14 切换到 MSVC16 会导致"compiler is out of heap space (C1060)"错误
- C++ DLL 运行时错误"abc.dll is not a valid WIN32 application" 。请帮助解决这个问题
- 如何修复此错误"the value of 'x1' is not usable in a constant expression"?static_assert
- 在析构函数中调用"delete"运算符时"compiler is out of heap space"编译器错误
- 巴泽尔中的错误"name 'new_local_repository' is not defined"
- 如何修复 SDL2 "GLSL 3.30 is not supported"错误
- 函数模板(它是类模板的成员)的显式专用化会产生"partial specialization is not allowed"错误,为什么?
- CGAL 绘制函数在 Visual Studio 中给出'CGAL_USE_BASIC_VIEWER is not defined'错误
- 如何修复类函数"prototype does not match"和"cadidate is"错误
- Windows 10 环境中的"This version of XAudio2 is available only in Windows 8"错误
- CUDA 错误:"dynamic initialization is not supported for __device__, __constant__ and __shared__ variabl
- MAC OpenGL 着色器错误:"version '150' is not supported "
- 代码块和 G++ 错误"is private"
- G++ 编译错误"... is protected from within this context"而 clang 没有错误