My project compiles fine if I insert some code from the examples, but the program crashes with:
Unhandled exception at 0x552CEB8C (msvcr110d.dll) in comClient.exe: 0xC0000005: Access violation reading location 0x63697274.
If I use the EXACT same code in a new project it works just fine, does exactly what it's supposed to do.
Why isn't it working in my project?
Here's what I'm using:
try {
sql::Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
/* Create a connection */
driver = get_driver_instance();
con = driver->connect("address:port", "user", "pass");
/* Connect to the MySQL test database */
con->setSchema("database");
stmt = con->createStatement();
stmt->execute("TRUNCATE TABLE words");
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;
}
[Note]
Afer setting some breakpoints and using the debugger, it seems the crash happens on:
con = driver->connect("address:port", "user", "pass");
Obviously using a working address, user and pass.
Unhandled exception at 0x552CEB8C (msvcr110d.dll) in comClient.exe: 0xC0000005: Access violation reading location 0x63697274.
If I use the EXACT same code in a new project it works just fine, does exactly what it's supposed to do.
Why isn't it working in my project?
Here's what I'm using:
try {
sql::Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
/* Create a connection */
driver = get_driver_instance();
con = driver->connect("address:port", "user", "pass");
/* Connect to the MySQL test database */
con->setSchema("database");
stmt = con->createStatement();
stmt->execute("TRUNCATE TABLE words");
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;
}
[Note]
Afer setting some breakpoints and using the debugger, it seems the crash happens on:
con = driver->connect("address:port", "user", "pass");
Obviously using a working address, user and pass.