mysql -uroot -p123456
i can connect to mysql with a terminal. but when i use the mysql c++ connector with jdbc, it fails. The exception says "unable to connect to localhost".
driver = sql::mysql::get_driver_instance();
try {
// con = driver->connect(connection, username, password);
con = driver->connect("tcp://127.0.0.1:3306", "root", "123456");
}
catch (sql::SQLException e) {
std::cout << e.what();
}
con->setSchema("mydb");
I am using mysql cpp connector8 jdbc api. but i always get the error unable connect to localhost. any help?