mardi 9 mars 2021

error while trying to insert data to mysql using c++ connector

try
    {
        driver = get_driver_instance();
        con = driver->connect(SQserver, username, password);
    }
    catch (sql::SQLException e)
    {
        std::cout << "Could not connect to server. Error message: " << e.what() << std::endl;
        exit(1);
    }

    con->setSchema("gt");

    pstmt = con->prepareStatement("INSERT INTO player(username, password) VALUES(?,?)");
    pstmt->setString(1, "name");
    pstmt->setString(2, "123456");
    pstmt->execute();

    delete pstmt;
    delete con;

so i have read the example in the mysql website and i tried to use that example and im getting this error

Could not connect to server. Error message: Access denied for user 'name'@'localhost' (using password: YES)

thats the same example in mysql website

Thanks.

Aucun commentaire:

Enregistrer un commentaire