mysql cpp connector throwing UnknownException while connecting
Posted by: adi adi
Date: November 09, 2011 11:18AM

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

Options: ReplyQuote


Subject
Views
Written By
Posted
mysql cpp connector throwing UnknownException while connecting
1427
November 09, 2011 11:18AM


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.