help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Exceptions are not cought


From: Stefan Kristensen
Subject: Exceptions are not cought
Date: Sat, 17 Nov 2007 19:50:42 +0100
User-agent: Thunderbird 2.0.0.9 (Windows/20071031)

Hello again :-)

In my everlasting search for knowledge, I have come to the issue of databases. I am using MySQL on a FreeBSD box.

After some issues with include paths and libraries, I managed to get in contact with the database and retrieve some records so the program and database works. Time to combine with some of the other stuff I have learned:

When connecting to the database, I used the following:
if(!mysql_real_connect(connect,SERVER,USER,PASSWORD,DATABASE,0,NULL,0)){
 cout << "Oops: " << mysql_error(connect) << endl;
 return 1;
}

This works as it should and tells me if the connection fails (e.g. wrong password).

But if I do this instead:
  try{
   mysql_real_connect(connect,SERVER,USER,PASSWORD,DATABASE,0,NULL,0);
  }catch(...){
   cout << "Oops: " << mysql_error(connect) << endl;
   return 1;
  }

I get the following error: Segmentation fault (core dumped) (i.e. not the mysql error as expected).

What am I doing wrong?

Best regards
Stefan


Oh, and I still wonder why #include <mysql/mysql.h> doesn't work, but I have to use the -Ipath-to-mysql.h option?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]