Unable to connect to MySQL server using mysql c++ connector

In this forum you can discuss database related issues which can be wxWidgets related, but also generic in nature.
Post Reply
Nishal
In need of some credit
In need of some credit
Posts: 5
Joined: Wed Apr 17, 2013 10:01 am

Unable to connect to MySQL server using mysql c++ connector

Post by Nishal »

I would like to develop a application in c++ in which I want to use MySQL for storing data in my database. I am connecting to the database through "MySQL C++ connector 1.1.3" library....

The problem is that when the "driver->connect(--parameters--)" function is executed, the program crashes. I'm sure that the program crashes while executing this function because I've checked it by using suitable output statements...

I have already downloaded the C++ connector and set the required options in the IDE. So, there is no problem with compilation and the program building properly as well....

I'm using code::blocks 12.11 as my IDE and MinGW 4.7.1 as my compiler...

I didn't install MySQL separately. Instead, I installed the XAMPP package, of which MySQL is a part.

I feel that the error is because the program is not able to access the MySQL database because it is not installed as MySQL instead its a part of XAMPP package.

Now, I don't want to install the MySQL server separately. I want to continue with the XAMPP package itself....

Please help!!!!
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re: Unable to connect to MySQL server using mysql c++ connec

Post by evstevemd »

Post backtrace and error message of the crash!
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Nishal
In need of some credit
In need of some credit
Posts: 5
Joined: Wed Apr 17, 2013 10:01 am

Re: Unable to connect to MySQL server using mysql c++ connec

Post by Nishal »

Well, it's been quite a long time since I have posted this thread. I didn't get a reply for a long time. So, I tried finding it out myself and found that it was because the libmysql.dll file that is required for accessing the database was built using visual c++. But I was using mingw. Hence, I decided to go with mysql++. I have successfully built it and have been able to build programs performing required operations successfully. Anyway, I thank you for your reply and I appreciate that you did reply. =D>
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re: Unable to connect to MySQL server using mysql c++ connec

Post by evstevemd »

Nishal wrote:Well, it's been quite a long time since I have posted this thread. I didn't get a reply for a long time. So, I tried finding it out myself and found that it was because the libmysql.dll file that is required for accessing the database was built using visual c++. But I was using mingw. Hence, I decided to go with mysql++. I have successfully built it and have been able to build programs performing required operations successfully. Anyway, I thank you for your reply and I appreciate that you did reply. =D>
Sorry that no body had responded. Thats the way volunteer driven forums are.
Glad that you resolved it.
wxEnjoyIt!
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
rafsanmoney
Experienced Solver
Experienced Solver
Posts: 72
Joined: Tue Oct 01, 2013 11:35 am
Contact:

Re: Unable to connect to MySQL server using mysql c++ connec

Post by rafsanmoney »

I would be glad if you could show me a step by step way of using the mysql++ library. I have built the library on mingw and have been able to connect to a database successfully. unfortunately, i connected to the database in a different way, my declaring a pointer to the Connection object. i.
mysqlpp::Connection *conn = new mysqlpp::Connection;
if i try to do it the usual way, i. e. mysqlpp::Connection con; app crashes.
even though the pointer works well for a successful connection. executing a query also crashes all the time. all the example programs crash. i don't know why, maybe you can give me an insight since i believe you are now familiar with the library.
Thanks in advance.
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re: Unable to connect to MySQL server using mysql c++ connec

Post by evstevemd »

rafsanmoney wrote:I would be glad if you could show me a step by step way of using the mysql++ library. I have built the library on mingw and have been able to connect to a database successfully. unfortunately, i connected to the database in a different way, my declaring a pointer to the Connection object. i.
mysqlpp::Connection *conn = new mysqlpp::Connection;
if i try to do it the usual way, i. e. mysqlpp::Connection con; app crashes.
even though the pointer works well for a successful connection. executing a query also crashes all the time. all the example programs crash. i don't know why, maybe you can give me an insight since i believe you are now familiar with the library.
Thanks in advance.
If I was to give advice I would suggest you use wxDatabase. it plays well with wxWidgets!
https://github.com/mtangoo/wxDatabase
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
rafsanmoney
Experienced Solver
Experienced Solver
Posts: 72
Joined: Tue Oct 01, 2013 11:35 am
Contact:

Re: Unable to connect to MySQL server using mysql c++ connec

Post by rafsanmoney »

i opened the url and it looks like there are just source files there. should i take them and build myself or what? can you give me a little walkthrough?
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re: Unable to connect to MySQL server using mysql c++ connec

Post by evstevemd »

rafsanmoney wrote:i opened the url and it looks like there are just source files there. should i take them and build myself or what? can you give me a little walkthrough?
I was waiting for someone who had bakefiles and said would contribute. Since he had not, I need to write them and will do that when I have time.
For now you have to include sources and put right switches to your library and build it. Which backed do you plan to use? MySQL only? Which IDE do you use?
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
rafsanmoney
Experienced Solver
Experienced Solver
Posts: 72
Joined: Tue Oct 01, 2013 11:35 am
Contact:

Re: Unable to connect to MySQL server using mysql c++ connec

Post by rafsanmoney »

I use code::blocks and i want to use just mysql.
Post Reply