I am using mysql library to connect to my database (mysql) to retrieve the data after connecting. Checked that my services are running properly.
Following is the part of code that does the connecting task..
<code>
. . .
// Specify our connection target and credentials
const string server = "tcp://127.0.0.1:3306";
const string username = "root";
const string password = "";// No password - thanks, WAMP Server!
// Try to get a driver to use to connect to our DBMS
try {
driver = get_driver_instance();
if( driver == NULL )
throw SQLException("Null driver instance returned.");
}
catch (SQLException e) {
cout << "Could not get a database driver. Error message: " << e.what() << endl;
return -3;
}
// Try to connect to the DBMS server
try {
dbConn = driver->connect(server, username, password);
}
catch (sql::SQLException e) {
cout << "Could not connect to database. Error message: " << e.getSQLStateCStr() << " Error Code: " << e.getErrorCode() << endl;
cout << "Could not connect to database. Error: " << e.what() << endl;
return -1;
}
. . .
</code>
It compiles well but gives an unknown exception with unknown debug info. Something like this. Please help.
Refer stackoverflow for full details....
http://stackoverflow.com/questions/8066599/mysql-cpp-connector-throwing-unknownexception-while-connecting