4 messages in com.mysql.lists.plusplusRe: Getting a segfaul
FromSent OnAttachments
Dovid Kopel14 Nov 2004 15:17 
Warren Young15 Nov 2004 05:27 
Warren Young15 Nov 2004 06:41 
Warren Young16 Nov 2004 17:30 
Subject:Re: Getting a segfaul
From:Warren Young (mysq@etr-usa.com)
Date:11/15/2004 05:27:20 AM
List:com.mysql.lists.plusplus

Dovid Kopel wrote:

#include "mysql.h"

That isn't necessary. It's included indirectly by mysql++.h.

using namespace std;

You might as well say 'using namespace mysqlpp' here as well.

mysqlpp::Query query = con.query(); query << "select * from cars"; cout << "Query: " << query.preview() << endl; mysqlpp::Result res = query.store();

Try use() here instead of store(), and put the result in a ResUse object.

catch (mysqlpp::BadQuery er)

You can catch this one by const reference, which is more efficient, and may stop the crash.

Query: select * from cars Error: Segmentation fault

Clearly a segfault is happening. It would be nice if trying to dump the error didn't cause it, but you ought to check things like passwords, table names, etc. I think you're not connecting to your database correctly, or using it correctly.