宣佈繼從MySQL C++連接器上的MySQL網站上的語法,但沒有很好的效果,這裏是一個片段:錯誤:「司機」不是在這個範圍內
:#include "/usr/include/mysql++/mysql++.h"
#include "/usr/include/mysql/mysql.h"
#include "/usr/include/mysql/mysql_version.h"
#include "/usr/include/mysql_connection.h"
#include "/usr/include/mysql_driver.h"
#include <cppconn/driver.h>
#include <cppconn/connection.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#include <cppconn/prepared_statement.h>
using namespace std;
using namespace sql::mysql;
using namespace sql;
sql::mysql::MySQL_Driver *driver;
driver = sql::mysql::get_mysql_driver_instance();
sql::Connection *con;
con = driver->connect("tcp://127.0.0.1:3306", "db", "password");
sql::PreparedStatement *prep_stmt;
prep_stmt = con->prepareStatement("INSERT INTO db(srcIP, srcCountry, destIP, destHost, destPort, blIP) VALUES (?, ?, ?, ?, ?, ?)");
prep_stmt->setString(1, src_ip);
prep_stmt->setString(2, country_code);
prep_stmt->setString(3, dest_ip);
prep_stmt->setString(4, host_name);
prep_stmt->setString(5, dest_prt);
prep_stmt->setString(6, blip);
prep_stmt->execute();
delete prep_stmt;
delete con;
}
else
sql::mysql::MySQL_Driver *driver;
driver = sql::mysql::get_mysql_driver_instance();
sql::Connection *con;
con = driver->connect("tcp://127.0.0.1:3306", "db", "password");
sql::PreparedStatement *prep_stmt;
prep_stmt = con->prepareStatement("INSERT INTO db(srcIP, srcCountry, destIP, destHost, destPort, blIP) VALUES (?, ?, ?, ?, ?, ?)");
prep_stmt->setString(1, src_ip);
prep_stmt->setString(2, country_code);
prep_stmt->setString(3, dest_ip);
prep_stmt->setString(4, he->h_name);
prep_stmt->setString(5, dest_prt);
prep_stmt->setString(6, blip);
prep_stmt->execute();
delete prep_stmt;
delete con;
與編譯
g ++ sql.c -o sql -I/usr/include -I/usr/include/mysql -I/usr/include/mysql ++ -I/usr/local/include -I/usr/local/include/cppconn -lmysqlcppconn -lmysql ++ -lstdC++ -lmysqlpp -lmysqlclient
並總是在第二組MySQL驅動程序上得到錯誤:
錯誤:「驅動程序」在此範圍
功能......你的邏輯通常駐留在功能... –
我很抱歉,因爲我是新來的編程(可能是一個月),我不覺得自己有足夠的信心開始回答問題。我很抱歉,但我不確定函數的評論是什麼。 – SP3CH8TR
我的意思是你提出了問題(確切地說七個問題),但沒有接受任何答案作爲答案。你應該花點時間,回去,並接受解決你的問題的答案。 –