My code:
try {
sql::Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
/* Create a connection */
driver = get_driver_instance();
con = driver->connect("tcp://127.0.0.1:3306", "root", "123456");
stmt = con->createStatement();
stmt->executeQuery("CREATE USER 'user22'");
delete stmt;
delete con;
} catch (sql::SQLException &e) {
cout << "# ERR: " << e.what();
cout << " (MySQL error code: " << e.getErrorCode();
cout << ", SQLState: " << e.getSQLState() << " )" << endl;
}
Creates the user22 but also throws an (empty?) exception:
# ERR: (MySQL error code: 0, SQLState: 00000 )
Of course, re-executing it results in proper exception:
# ERR: Operation CREATE USER failed for 'user22'@'%' (MySQL error code: 1396, SQLState: HY000 )
Commenting the executeQuery
line results in no exceptions (blank output)
Is this common? Should I just ignore this?