Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Need tutorial on how to set up and use MySql Connector/C++ in eclipse on my M1 Macbook(How do I get eclipse on my M1 Macbook work with MySql Connector/C++)
Need tutorial on how to set up and use MySql Connector/C++ in eclipse on my M1 Macbook [message #1862531] Sat, 09 December 2023 15:54
Dean Rochester is currently offline Dean RochesterFriend
Messages: 1
Registered: July 2009
Junior Member
I have downloaded
and I am using
Eclipse IDE for C/C++ Developers (includes Incubating components)

Version: 2023-12 (4.30.0)
Build id: 20231201-2043

I made a new C++ project and have tried both
Cross GCC

I put the path to the include directory
In the C/C++ General > Path and Symbols

Then I tried to do a simple program to connect to my local MySql database using the following... and I get errors saying it cant resolve the header files.

/* Standard C++ includes */
#include <stdlib.h>
#include <iostream>

Include directly the different
headers from cppconn/ and mysql_driver.h + mysql_util.h
(and mysql_connection.h). This will reduce your build time!

/* None of these header files will it locate */
#include <mysql.h>
#include <mysqlx/xdevapi.h>
#include "mysql_connection.h"

#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>

using namespace std;

int main(void)
cout << endl;
cout << "Running 'SELECT 'Hello World!' »
AS _message'..." << endl;

try {
sql::Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
sql::ResultSet *res;

/* Create a connection */
driver = get_driver_instance();
con = driver->connect("tcp://", "root", "root");
/* Connect to the MySQL test database */

stmt = con->createStatement();
res = stmt->executeQuery("SELECT 'Hello World!' AS _message");
while (res->next()) {
cout << "\t... MySQL replies: ";
/* Access column data by alias or column name */
cout << res->getString("_message") << endl;
cout << "\t... MySQL says it again: ";
/* Access column data by numeric offset, 1 is the first column */
cout << res->getString(1) << endl;
delete res;
delete stmt;
delete con;

} catch (sql::SQLException &e) {
cout << "# ERR: SQLException in " << __FILE__;
cout << "(" << __FUNCTION__ << ") on line " »
<< __LINE__ << endl;
cout << "# ERR: " << e.what();
cout << " (MySQL error code: " << e.getErrorCode();
cout << ", SQLState: " << e.getSQLState() << " )" << endl;

cout << endl;

Previous Topic:can't format c++ code
Next Topic:Attempting to set up C environment in Eclipse & getting "Content is not in prolog" err
Goto Forum:

Current Time: Fri May 24 22:43:23 GMT 2024

Powered by FUDForum. Page generated in 0.02992 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top