ExclamationMySQL using C++

Posts 1–3 of 3 · Page 1 of 1
MySQL using C++
Hi (:

Maybe here someone can help me...
I'm trying to connect to mySQL table but i fail everytime, but it something with the connector files, cant get it to work, donwloaded boost lib, server lib, mysqlconnector lib, and nothing, nothing works :/

 
CODE THAT I'M TESTING
Code:
/* 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!
*/
#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"); // replace with your statement
  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;
}
I now that it got errors but is errors like this », i just copied again and paste here, but all the headers get underlined in red saying that is not included


Maybe someone here can help me to include this files, or have a guide/video for this, i found a lot of them and no one works :/
@Camel @OP I can't open the spoiler.
Quote Originally Posted by RoPMadM View Post
@Camel @OP I can't open the spoiler.
Same with me .-. but i already solved, anyway thankx (;

I'm using phpMyAdmin for get the database.

//SOLVED plz close
Posts 1–3 of 3 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us