EclipseCDT - MySQLConnector/C++ no Windows XP

0 respostas
JxtaNode

Bon dia,

Nao consigo utilizar MySQL num programma C++ com ECLIPSE CDT / Cygwin no Windows XP.

Minha installação :

–> Windows XP
–> Cygwin
–> jdk1.6 / Eclipse-cpp-galileo-SR1-win32
–> WAMPServer2.0 ( MySQL 5.1.36)
–> MySQL Connector/C++ is a MySQL database connector for C++

Meu programa C++ :

//----------------------------------TEST DRIVER MySQL Connector C++  --------------------
 
/* Standard C++ includes */
#include <stdlib.h>
#include <iostream>
 
#include <mysql_connection.h>
#include <mysql_driver.h>
 
#include <cppconn/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", "");
  /* Connect to the MySQL test database */
  con->setSchema("testdb");
 
  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;
}
 
//--------------------------------------------------------

Configuration do Eclipse CDT :

Dentro de "Properties/C/C++Build/settings"
Dentro “Cygwing C++ Compiler/Directories” includes files :

eu meti :
“C:\cygwin\usr\include\w32api”
“C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\include”
“C:\cygwin\usr\include”
“C:\cygwin\lib\gcc\i686-pc-cygwin\3.4.4\include\c++”

Dentro “Cygwin C++ Linker/Libraries” :
Dentro libraries(-l) : mysqlcppconn

Dentro "Library search path (-L) " :
“C:\Program Files\MySQL\MySQL Connector C++ 1.0.5\lib\opt”

Fiz um Ctrl+B no Eclipse CDT

MAS problema na execução (RUN AS) :

//--------------------ERREUR-----------------------------------
**** Build of configuration Debug for project testtConnectorBDDcpp ****

make all
ConnectionBdd.d:1: *** multiple target patterns. Stop.
//--------------------------------------------------------------
Li iste link, mas nada :
http://forge.mysql.com/wiki/Connector_C%2B%2B

Talvez a solução seja utilizare MySQL++ no Win XP com Eclipse.
http://tangentsoft.net/mysql++/doc/html/userman/

Se você tiver uma idea obrigado.

If you have one idea, thanks in advance.

Best reagards

Criado 11 de outubro de 2009
Respostas 0
Participantes 1