1
目前,我已经实现了一个程序来写入到mysql数据库...我也使用Xcode与c + +。我已经正确导入了所有的库,但是我在这一行上收到了一个BAD EXCESS错误消息:连接崩溃在mysql c + +
con = driver->connect("tcp://127.0.0.1:3306", "root", "root");
什么似乎是问题?继承人的全部程序...
#include <stdlib.h>
#include <iostream>
// Include directly the different
// headers from cppconn/ and mysql_driver.h + mysql_util.h
// (and mysql_connection.h). This will reduce your build time!
#include "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 << endl;
cout << "Running 'SELECT 'Hello World!' AS _message'..." << endl;
try {
sql::Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
sql::ResultSet *res;
// Create a connection
driver = get_driver_instance();
con = driver->connect("tcp://127.0.0.1:3306", "root", "root");
// Connect to the MySQL test database
con->setSchema("test");
stmt = con->createStatement();
res = stmt->executeQuery("SELECT 'Hello World!' AS _message");
while (res->next()) {
cout << "\t... MySQL replies: ";
// Access column data by alias or column name
cout << res->getString("_message") << endl;
cout << "\t... MySQL says it again: ";
// Access column fata by numeric offset, 1 is the first column
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;
}
cout << endl;
return EXIT_SUCCESS;
}
编辑所以目前,我看着这个topic这是几乎完全相似,我的,但我仍然这样就失去了......我怎么会重新编译MySQL的使用CMake和变化这样的标志?
我一直在这个问题上几个小时,没有编码确实已经完成......就在我盯着屏幕与面容> :(。
感谢您的输入...它基本上是相同的:)我要它更深入地了解并得到很快有望运行 – jsetting32