driver->connect() Segmentation Fault
I could compile this code with no error messages. But when I execute the binary I get a segmentation fault error. The problem is in this line:
con = driver->connect("tcp://127.0.0.1:3306", "root", "*******");
I've tried a lot of things and I'm out of ideas. Even though compilation was ok, maybe I made a mistake there somehow.
If you can help me I will really appreciate it.
-----------------------------------------------------
#include <stdlib.h>
#include <iostream>
#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::mysql::MySQL_Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
sql::ResultSet *res;
driver = sql::mysql::get_mysql_driver_instance();
con = driver->connect("tcp://127.0.0.1:3306", "root", "*******");
} 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;
}
Subject
Views
Written By
Posted
driver->connect() Segmentation Fault
2406
December 18, 2016 06:49PM
1031
December 18, 2016 06:55PM
1151
December 21, 2016 09:41AM
1295
December 21, 2016 10:19AM
1056
December 21, 2016 05:27PM
932
December 21, 2016 08:19PM
915
December 21, 2016 10:21AM
1500
March 16, 2017 06:06PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.