How to fix “bad_alloc” error when connecting to MySQL database using C++ connector?

I’m facing an issue when executing my C++ project on Windows. I use CMake to compile my project and I’ve managed to compile it without any errors. However, when I try to execute it, I encounter an “aborted()” error with no further details.

Here are some key points about my project and the issue I’m facing:

  • Environment and tools used: I’m working on Windows and using CMake to generate the build files for my project. The compilation is done with cl.exe.

  • Using MySQL Connector for C++: My project utilizes MySQL Connector/C++ to communicate with a remote MySQL database. I’ve included the appropriate header files and configured my project to link the MySQL Connector libraries.

  • Successful compilation: Compilation proceeds without errors, indicating that the header files and libraries are properly configured in my project.

  • “aborted()” error on execution: However, when I attempt to execute my project, an “aborted()” error occurs with no further details. This error occurs immediately after my program starts.

  • Available and operational database: The MySQL database my program is trying to connect to is available and operational. I can connect to this database using other database manipulation tools without encountering any errors.

I would greatly appreciate any help or suggestions to resolve this issue. If you have any ideas on what might be causing this “aborted()” error during the execution of my program, or if you have suggestions for debugging it more effectively, I would be grateful to hear them.

This is my test code :

#include <mysql/jdbc.h>
#include "db.hpp"

void start(void) {
    //In my code, there are the litterals, not here for security
    auto db = sql::mysql::get_driver_instance();
    sql::SQLString host { /*hostname*/ };
    sql::SQLString user { /*username*/ };
    sql::SQLString passwd { /*password*/ };
    auto connexion = db->connect(host, user, passwd);
}

The manual didn’t help me at all.

Here’s a summary of the steps I’ve taken to address the issue so far:

  • Isolating the error: I attempted to isolate the error by narrowing down potential causes, but unfortunately, the error seems too critical to proceed with meaningful debugging.

  • Allocating more memory: I tried manually allocating more memory during compilation to see if it would alleviate the issue, but it didn’t have any effect on the “aborted()” error during execution.

  • Debugging: I extensively debugged the code to identify any logical errors or memory leaks that could be contributing to the problem. However, the error persists despite these efforts.

  • Reviewing documentation: I carefully reviewed the documentation for MySQL Connector/C++ to ensure that I haven’t overlooked any crucial steps or configurations required for proper usage. Everything appears to be correctly implemented based on the documentation.

  • Checking DLL locations: I verified the location of the required DLL files both during compilation and execution to ensure they are accessible. However, this doesn’t seem to be the source of the issue.

Despite these attempts, I’m still unable to resolve the “aborted()” error during execution of my C++ program using MySQL Connector/C++. My ultimate goal is to establish communication with my remote MySQL server and manipulate the tables. Alternatively, I’d like to at least retrieve data from the available tables without altering any existing data.

Any insights or suggestions would be greatly appreciated. Thank you in advance for your assistance!

New contributor

Lucas Espinar is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật