title: Connecting to MySQL From Eclipse (CDT)
body: <p>I tried to connect to MySQL database by C++ in Eclipse with all the recommendations that are on the internet, but none of them are fully helpful. I am using Eclipse with MinGW to connect to MySQL. 
  I have added the:</p>
  
  <pre><code>C:\Program Files\boost
  C:\Program Files\MySQL\MySQL Connector C++ 1.1.3\include
  C:\Program Files\MySQL\MySQL Server 5.6\include
  </code></pre>
  
  <p>to the include directory and</p>
  
  <pre><code>C:\Program Files\MySQL\MySQL Server 5.6\lib
  C:\Program Files\MySQL\Connector C++ 1.1.2\lib\opt
  </code></pre>
  
  <p>to Library Directories (-L). Also I added the</p>
  
  <pre><code>libmysql.lib
  mysqlcppconn-static.lib
  </code></pre>
  
  <p>to Additional Dependencies (-l).</p>
  
  <p>The code is:</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;iostream&gt;
  
  #include "mysql_driver.h"
  #include "mysql_connection.h"
  
  #include &lt;cppconn/driver.h&gt;
  #include &lt;cppconn/exception.h&gt;
  #include &lt;cppconn/resultset.h&gt;
  #include &lt;cppconn/statement.h&gt;
  
  using namespace std;
  using namespace sql::mysql;
  
  int main(void)
  {
  cout &lt;&lt; endl;
  cout &lt;&lt; "Running 'SELECT 'Hello World!' AS _message'..." &lt;&lt; endl;
  
  try {
    sql::Driver *driver;
    sql::Connection *con;
    sql::Statement *stmt;
    sql::ResultSet *res;
  
    /* Create a connection */
    driver = get_driver_instance();
    con = driver-&gt;connect("tcp://127.0.0.1:3306", "root", "root");
    /* Connect to the MySQL test database */
    con-&gt;setSchema("test");
  
    stmt = con-&gt;createStatement();
    res = stmt-&gt;executeQuery("SELECT 'Hello World!' AS _message");
    while (res-&gt;next()) {
      cout &lt;&lt; "\t... MySQL replies: ";
      /* Access column data by alias or column name */
      cout &lt;&lt; res-&gt;getString("_message") &lt;&lt; endl;
      cout &lt;&lt; "\t... MySQL says it again: ";
      /* Access column fata by numeric offset, 1 is the first column */
      cout &lt;&lt; res-&gt;getString(1) &lt;&lt; endl;
    }
    delete res;
    delete stmt;
    delete con;
  
  } catch (sql::SQLException &amp;e) {
    cout &lt;&lt; "# ERR: SQLException in " &lt;&lt; __FILE__;
    cout &lt;&lt; "(" &lt;&lt; __FUNCTION__ &lt;&lt; ") on line " &lt;&lt; __LINE__ &lt;&lt; endl;
    cout &lt;&lt; "# ERR: " &lt;&lt; e.what();
    cout &lt;&lt; " (MySQL error code: " &lt;&lt; e.getErrorCode();
    cout &lt;&lt; ", SQLState: " &lt;&lt; e.getSQLState() &lt;&lt; " )" &lt;&lt; endl;
  }
  
  cout &lt;&lt; endl;
  
  return EXIT_SUCCESS;
  }
  </code></pre>
  
  <p>But none of them seems to work and lots of errors pops up. For now I get an error on
  <code>"call of overloaded 'get_driver_instance()' is ambiguous"</code> Does any of you guys have an experience to connect to MySQL through Eclipse in C++ environment. I am not a Linux user and the tutorial on Linux didn't work either. </p>