1

Currently, I have implemented a program to write to a mysql database... I am using Xcode with c++as well. I have imported all the libraries correctly but I'm getting a BAD EXCESS error message on this line :

    con = driver->connect("tcp://127.0.0.1:3306", "root", "root");

What seems to be the issue? Heres the full program...

#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!

#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://127.0.0.1:3306", "root", "root");
        // Connect to the MySQL test database
        con->setSchema("test");
        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 fata 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;
    return EXIT_SUCCESS;
}

EDIT So currently, I looked at this topic which is almost exactly similar to mine but I am still so lost... How would I recompile mysql with cmake and change such flags?

I have been at this issue for several hours and no coding has really been done... Just staring at my screen with a face >:(.

Community
  • 1
  • 1
jsetting32
  • 1,632
  • 2
  • 20
  • 45

1 Answers1

1

Here's a similar problem (almost identical?), have you checked it?

Community
  • 1
  • 1
Zelix
  • 1,914
  • 1
  • 14
  • 11
  • Thanks for your input... it basically is the same :) I'll have a deeper look at it and get it running soon hopefully – jsetting32 Jul 31 '13 at 20:58