My code:
try {
sql::Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
/* Create a connection */
driver = get_driver_instance()
You are using executeQuery, which supposed to return sql::ResultSet object, and you are quering "CREATE USER" which returns true or false.
There is an execute method for such cases. So...
stmt = con->createStatement();
stmt->execute("CREATE USER 'user22'");
won't throw an error.
Yeah, i know that the post is 2 years old, but if someone bumps in to the same problem in future could be of use to them.