Code::Blocks - Std::bad_alloc

Asked

Viewed 71 times

0

After I run this simple code.

#include <iostream>

#include <jdbc/cppconn/connection.h>
#include <jdbc/cppconn/driver.h>

int main()
{
    sql::Connection *con;
    sql::Driver *driver;

    std::cout << "connecting to mysql server..." << std::endl;

    driver = get_driver_instance();
    con = driver->connect("localhost", "root", "");
    std::cout << "connecting to mysql server with sucessfully...." << std::endl;
    std::cout << con->isClosed() << std::endl;
    std::cout << "ate aqui o programa executa normalmente.." << std::endl;
    con->setSchema("secao05"); // Dispara o erro nesta linha
    std::cout << "Apos o erro nada e executado!" << std::endl;

    delete con;

    return 0;
}

error on line 18: inserir a descrição da imagem aqui

The database I’m trying to connect to also and very small has only 10 INSERT.

EDIT:

When I change the compiler version from c++17 to c++11 the error changes to:

terminate called after Throwing an instance of 'sql::Sqlexception'
what(): Unknown database’t' Aborted (core dumped)

Process returned 134 (0x86) Execution time : 0.299 s Press ENTER to continue.

  • Check the versions of your server and jdbc. Search whether the incompatibility has been fixed in the versions in use.

  • Server version: 8.0.17, and the Connector version is Connector/C++ 8.0.17, both are the most updated versions on the official mysql website

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.