Hi i can get the program to connect to the database but as soon as i
attempt to retrieve a result set it Seg Faults and i can't figure out
why. As you can see i've added extra catch( ...)'s to ensure i'm not
missing any exceptions.
Here is the code:
//declaired private in the class containing this code block
Connection *dbCon;
//initialize database
try
{
dbCon = new Connection(use_exceptions);
if(dbCon->real_connect(DB,HOST,USERNAME,PASSWORD,3306,0,60,"/tmp/mysql.sock")
!= true)
{
cerr << "ERROR::" << "Database connection Error" << endl;
}
}
catch(BadQuery er)
{
cerr << "ERROR::" << er.error << endl;
}catch(...){
cerr << "ERROR::" << " unhandled database connection exception" <<
endl;
}
cerr << "database connection initialized" << endl;
//initialize universe
someclass->Load(dbCon);
//loadfunction
int SomeClass::Load(Connection *dbCon)
{
try{
//create query object
Query query = dbCon->query();
query << "select * from sometable";
cerr << "added query string : " << query.preview() << endl;
Result res = query.store();
//segfaults on this line ... never see the following output
cerr << "ran select query" << endl;
//loops through all worlds returned from query
Row world;
Result::iterator i;
for (i = res.begin(); i != res.end(); i++) {
//cdo stuff
}
return 0;
} catch (BadQuery er) { // handle bad querys
cerr << "ERROR:: " << er.error << endl;
} catch (BadConversion er) { // handle bad conversions
cerr << "ERROR:: " << "bad conversion in Load Universe" << endl;
} catch(...){
cerr << "ERROR:: " << "unhandled exception" << endl;
}
}
--
Thanks for your time,
Chris Gagnon