Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Connect Mysql And Eclipse c++
Connect Mysql And Eclipse c++ [message #1703523] Sun, 02 August 2015 13:12 Go to next message
Danial Atash is currently offline Danial AtashFriend
Messages: 7
Registered: March 2015
Junior Member
i trying to connect mysql database and eclipse c++ and i set everything but when i want to compile a program using data base this error massage appears:

"fatal error:boost/shared_ptr.hpp: no such file or directory"

*****************************************************


how can i fix it, there is no solution on the internet, and i really really really tired of searching about this.

my compiler: gcc
my os: windows 8.1
**********************************
here you can see my code:

#include <stdlib.h>
#include <iostream>
#include "mysql_connection.h"
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#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", "37975");
/* 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;
}
Re: Connect Mysql And Eclipse c++ [message #1703526 is a reply to message #1703523] Sun, 02 August 2015 14:35 Go to previous messageGo to next message
Eclipse UserFriend
Be sure to having the boost library included in your project.

I don't see it in your Includes section. Do you have it included in your Tool Settings in Eclipse?

Check: Project -> Settings -> Libraries

-- L. James

--
L. D. James
ljames@apollo3.com
www.apollo3.com/~ljames

Danial Atash wrote on Sun, 02 August 2015 13:12
i trying to connect mysql database and eclipse c++ and i set everything but when i want to compile a program using data base this error massage appears:

"fatal error:boost/shared_ptr.hpp: no such file or directory"

*****************************************************


how can i fix it, there is no solution on the internet, and i really really really tired of searching about this.

my compiler: gcc
my os: windows 8.1
**********************************
here you can see my code:

#include <stdlib.h>
#include <iostream>
#include "mysql_connection.h"
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#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", "37975");
/* 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;
}

Re: Connect Mysql And Eclipse c++ [message #1703639 is a reply to message #1703526] Mon, 03 August 2015 18:44 Go to previous messageGo to next message
Danial Atash is currently offline Danial AtashFriend
Messages: 7
Registered: March 2015
Junior Member
i don't know how i can add boost lib to my eclipse.
i trying to fix this problem but i cant. i'm very depressed by it.
but please help me, how can i add boost library to my eclipse on windows platform.
sincerely yours, Daniel
Re: Connect Mysql And Eclipse c++ [message #1703642 is a reply to message #1703639] Mon, 03 August 2015 19:00 Go to previous messageGo to next message
Eclipse UserFriend
You'll have to start out by adding the header files to the project. My OS is Ubuntu. But I'm sure the same option and features are basically accessed the same on any OS running Eclipse.

Start out with:

Find out where on your computer your boost header files are located. It'll most likely be in a directory off the other includes. On my system the normal includes directory is:
/usr/include

The boost header files are located at:
/usr/include/boost

So I put this in the project's includes path:
/usr/include

Now everything under /usr/include will be searched.

(Right Click on your Project) -> Properties -> (expand) C/++ Build -> (click) Settings -> (click) Tool Settings -> Libraries -> (for Library search path put) /usr/include (or where ever your boost headers are.

You may or may not have to add some Libraries to the top part. The system may find them just by searching the headers. If you continue to get errors add the necessary libraries such as "boost_filesystem" and "boost_system" (or any others that your project is calling for.

-- L. James

--
L. D. James
ljames@apollo3.com
www.apollo3.com/~ljames

Danial Atash wrote on Mon, 03 August 2015 18:44
i don't know how i can add boost lib to my eclipse.
i trying to fix this problem but i cant. i'm very depressed by it.
but please help me, how can i add boost library to my eclipse on windows platform.
sincerely yours, Daniel

Re: Connect Mysql And Eclipse c++ [message #1703757 is a reply to message #1703642] Tue, 04 August 2015 17:34 Go to previous messageGo to next message
Danial Atash is currently offline Danial AtashFriend
Messages: 7
Registered: March 2015
Junior Member
i add boost to lib but it didn't work properly yet.
i tried to set eclipse and sqlite database too but it didn't work too and gave's error like mysql
the error was:" fatal error......"
i don't know why but it seems that eclipse don't support databases. why?
Re: Connect Mysql And Eclipse c++ [message #1703764 is a reply to message #1703757] Tue, 04 August 2015 18:18 Go to previous messageGo to next message
Eclipse UserFriend
Eclipse is a GUI interface environment for using the tools that you have installed. If you have a database development tools installed you can use the Eclipse environment to work with the programming.

Do you have a mysql development package installed? Also I see you have a "mysql_connection.h" include. Do you have any error or question mark associated with it?

Will you post the status of the includes you have?

For instance:

<code>
#include <stdlib.h>
#include <iostream>
? #include "mysql_connection.h"
? #include <cppconn/driver.h>
? #include <cppconn/exception.h>
? #include <cppconn/resultset.h>
? #include <cppconn/statement.h>
? #include <cppconn/prepared_statement.h>
</code>

-- L. James

--
L. D. James
ljames@ap;ollo3.com
www.apollo3.com/~ljames

Danial Atash wrote on Tue, 04 August 2015 17:34
i add boost to lib but it didn't work properly yet.
i tried to set eclipse and sqlite database too but it didn't work too and gave's error like mysql
the error was:" fatal error......"
i don't know why but it seems that eclipse don't support databases. why?

Re: Connect Mysql And Eclipse c++ [message #1703795 is a reply to message #1703764] Wed, 05 August 2015 05:44 Go to previous messageGo to next message
Danial Atash is currently offline Danial AtashFriend
Messages: 7
Registered: March 2015
Junior Member
i installed mysql server and c and c++ api and add it to my library in eclipse but i still see this error "fatal error:boost/shared_ptr.hpp: no such file or directory"
i don't know what is it, i installed boost library, i installed everything for making a database and i don't give a result.
if you can or it's easy to you please check and write something useful to connect mysql on eclipse(c++).
cause there is no page on the internet about it
Re: Connect Mysql And Eclipse c++ [message #1703912 is a reply to message #1703795] Wed, 05 August 2015 18:58 Go to previous messageGo to next message
Eclipse UserFriend
I asked you if you had any errors in your code. Will you look at the "include" block and tell me the status of each line?

Look at my previous message.

I don't see a reason why your code doesn't work. But I need to start somewhere by having feedback on this particular question.

-- L. James

--
L. D. James
ljames@apollo3.com
www.apollo3.com/~ljames

Danial Atash wrote on Wed, 05 August 2015 05:44
i installed mysql server and c and c++ api and add it to my library in eclipse but i still see this error "fatal error:boost/shared_ptr.hpp: no such file or directory"
i don't know what is it, i installed boost library, i installed everything for making a database and i don't give a result.
if you can or it's easy to you please check and write something useful to connect mysql on eclipse(c++).
cause there is no page on the internet about it

Re: Connect Mysql And Eclipse c++ [message #1704077 is a reply to message #1703912] Fri, 07 August 2015 08:12 Go to previous messageGo to next message
Danial Atash is currently offline Danial AtashFriend
Messages: 7
Registered: March 2015
Junior Member
my mySQL path is: "D:\Programs\Programming\MySQL\MySQL Server 5.5"
and my mysql-connector c++ path that i download it from mysql's website is: "D:\Programs\Programming\MySQL\Connector C++"
and my-boost library that i don't know what is it is: "D:\Programs\Programming\boost_1_57_0"

i go to the eclipse and select the Project>>properties>>c/c++ build>>GCC C++ Comiler>>Includes and add below Item to Include path:
- "D:\Programs\Programming\MySQL\Connector C++\include"
- "D:\Programs\Programming\MySQL\MySQL Server 5.5\include"
- "D:\Programs\Programming\boost_1_57_0\boost"

and then i go to the Project>>properties>>c/c++ build>>MINGW C++ Linker>> Libraries and add below items to library search path:
- "D:\Programs\Programming\MySQL\MySQL Server 5.5\lib"
- "D:\Programs\Programming\MySQL\Connector C++\lib"

now when i want to compile this program(from mysql example )


#include <stdlib.h>
#include <iostream>
#include "mysql_connection.h"
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#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", "37975");
/* 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;
}


i see it is dont compile and i see these errors:
- Description Resource Path Location Type
fatal error: boost/shared_ptr.hpp: No such file or directory Working line 31, external location: D:\Programs\Programming\MySQL\Connector C++\include\mysql_connection.h C/C++ Problem



i don't know why i cant connect mysql to eclipse. i tried to connect it more and more (at least 1 month)
Please Help me!!!!
Re: Connect Mysql And Eclipse c++ [message #1704115 is a reply to message #1704077] Fri, 07 August 2015 12:05 Go to previous messageGo to next message
Eclipse UserFriend
It's not clear if you understand my question.

Will you do me the favor of looking at your screen and tell me if there is a simple in front of any of the includes? Do you have a question mark "?" or any other error indicating that it can't find the include?

Thanks!

-- L. James

--
L. D. James
ljames@apollo3.com
www.apollo3.com/~ljames

Danial Atash wrote on Fri, 07 August 2015 08:12
my mySQL path is: "D:\Programs\Programming\MySQL\MySQL Server 5.5"
and my mysql-connector c++ path that i download it from mysql's website is: "D:\Programs\Programming\MySQL\Connector C++"
and my-boost library that i don't know what is it is: "D:\Programs\Programming\boost_1_57_0"

i go to the eclipse and select the Project>>properties>>c/c++ build>>GCC C++ Comiler>>Includes and add below Item to Include path:
- "D:\Programs\Programming\MySQL\Connector C++\include"
- "D:\Programs\Programming\MySQL\MySQL Server 5.5\include"
- "D:\Programs\Programming\boost_1_57_0\boost"

and then i go to the Project>>properties>>c/c++ build>>MINGW C++ Linker>> Libraries and add below items to library search path:
- "D:\Programs\Programming\MySQL\MySQL Server 5.5\lib"
- "D:\Programs\Programming\MySQL\Connector C++\lib"

now when i want to compile this program(from mysql example )


#include <stdlib.h>
#include <iostream>
#include "mysql_connection.h"
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include <cppconn/resultset.h>
#include <cppconn/statement.h>
#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", "37975");
/* 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;
}


i see it is dont compile and i see these errors:
- Description Resource Path Location Type
fatal error: boost/shared_ptr.hpp: No such file or directory Working line 31, external location: D:\Programs\Programming\MySQL\Connector C++\include\mysql_connection.h C/C++ Problem



i don't know why i cant connect mysql to eclipse. i tried to connect it more and more (at least 1 month)
Please Help me!!!!

Re: Connect Mysql And Eclipse c++ [message #1704177 is a reply to message #1704077] Sat, 08 August 2015 00:17 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
On 08/07/2015 03:12 AM, Danial Atash wrote:
> i see it is dont compile and i see these errors:
> - Description Resource Path Location Type
> fatal error: boost/shared_ptr.hpp: No such file or directory
> Working line 31, external location:
> D:\Programs\Programming\MySQL\Connector
> C++\include\mysql_connection.h C/C++ Problem
>

The compiler is looking for the boost/shared_ptr.hpp file in an Include
path subdirectory named boost. One of the include directories you added
ends with boost. Make sure that you aren't adding the wrong directory
to the path. If the shared_ptr.hpp file is in
"D:\Programs\Programming\boost_1_57_0\boost" that you added, then you
need to back this path entry up a level as
"D:\Programs\Programming\boost_1_57_0". The compiler with then look in
the boost subdirectory and find the header file.
Re: Connect Mysql And Eclipse c++ [message #1704246 is a reply to message #1704177] Sun, 09 August 2015 19:15 Go to previous message
Eclipse UserFriend
David Wegener wrote on Sat, 08 August 2015 00:17
On 08/07/2015 03:12 AM, Danial Atash wrote:
> i see it is dont compile and i see these errors:
> - Description Resource Path Location Type
> fatal error: boost/shared_ptr.hpp: No such file or directory
> Working line 31, external location:
> D:\Programs\Programming\MySQL\Connector
> C++\include\mysql_connection.h C/C++ Problem
>

The compiler is looking for the boost/shared_ptr.hpp file in an Include
path subdirectory named boost. One of the include directories you added
ends with boost. Make sure that you aren't adding the wrong directory
to the path. If the shared_ptr.hpp file is in
"D:\Programs\Programming\boost_1_57_0\boost" that you added, then you
need to back this path entry up a level as
"D:\Programs\Programming\boost_1_57_0". The compiler with then look in
the boost subdirectory and find the header file.


If someone can get him to show the status of his Include block it would be easy to identify if he has his includes configured correctly. The code he posted works fine.

To me that problem appears to be simple, but can't resolve it without knowing what the IDE is showing as a status.

-- L. James

--
L. D. James
ljames@apollo3.com
www.apollo3.com/~ljames
Previous Topic:How to get code and compile by different remote machine's?
Next Topic:Open Declaration only in current workspace
Goto Forum:
  


Current Time: Thu Apr 18 19:28:28 GMT 2024

Powered by FUDForum. Page generated in 0.03048 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top