MySQL Forums
Forum List  »  Connector/C++

C1083 Cannot open include file cppconn/connection.h
Posted by: ARNE BUE
Date: August 13, 2017 11:45AM

Help! I get the following C1083 error:
"Cannot open include file: 'cppconn/connection.h': No such file or directory.'

I am using VS2015. I have read C1083 but cannot get this fatal error corrected.

I am probably doing something stupid. Can someone help?

Here's the code entered.

// example.cpp : Defines the entry point for the console application.
//

/* Standard C++ includes */
#include "stdafx.h"
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <stdexcept>


/*
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 "C:/Program Files/MySQL/Connector.C++ 1.1/include/mysql_connection.h"

#include "C:/Program Files/MySQL/Connector.C++ 1.1/include/cppconn/connection.h"
#include "C:/Program Files/MySQL/Connector.C++ 1.1/include/cppconn/driver.h"
#include "C:/Program Files/MySQL/Connector.C++ 1.1/include/cppconn/exception.h"
#include "C:/Program Files/MySQL/Connector.C++ 1.1/include/cppconn/resultset.h"
#include "C:/Program Files/MySQL/Connector.C++ 1.1/include/cppconn/statement.h"
#include "C:/Program Files/MySQL/Connector.C++ 1.1/include/cppconn/prepared_statement.h"


using namespace std;

int main(void)
{
cout << endl;
cout << "Let's have MySQL count from 10 to 1..." << endl;


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

/* 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();
stmt->execute("DROP TABLE IF EXISTS test");
stmt->execute("CREATE TABLE test(id INT)");
delete stmt;

/* '?' is the supported placeholder syntax */

pstmt = con->prepareStatement("INSERT INTO test(id) VALUES (?)");
for (int i = 1; i <= 10; i++) {
pstmt->setInt(1, i);
pstmt->executeUpdate();
}
delete pstmt;

/* Select in ascending order */
pstmt = con->prepareStatement("SELECT id FROM test ORDER BY id ASC");
res = pstmt->executeQuery();

/* Fetch in reverse = descending order! */
res->afterLast();
while (res->previous())
cout << "\t... MySQL counts: " << res->getInt("id") << endl;
delete res;

delete pstmt;
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;
}

Options: ReplyQuote


Subject
Views
Written By
Posted
C1083 Cannot open include file cppconn/connection.h
189
August 13, 2017 11:45AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.