Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mysql cpp connector throwing UnknownException while connecting
- // 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;
- }
Add Comment
Please, Sign In to add comment