List:MySQL++« Previous MessageNext Message »
From:Maarten Schrijvers Date:October 2 2007 7:44pm
Subject:probleme with exeptions
View as plain text  
Hervé accidently sent this to my email...

Hello all,

I using mysql++-2.3.2 on hp-ux

I use a instance of
	mysqlpp::Connection m_db;

the exception it's normaly at true.

it's a example of use:
void OnLoadCalendrier()
{

	database.OpenConnection();
	string strlog;

	string sql;
	int nb_result;
	mysqlpp::Query query = database.m_db.query();
	mysqlpp::Row row;
	int nbgrp=0, nbcc=0;

	CCalendrier *cal;
	IteCal ite;
	
	try
	{
		
		sql = SQL_SELECT_CALENDRIER;
		query << sql;
		r->LogRoomSend((char*)sql.c_str());

		mysqlpp::Result res = query.store();
		nb_result = res.size();
		mysqlpp::Result::iterator i;
		if(res.num_rows()>=1)
		{
			for (i = res.begin(); i != res.end(); i++) {
				row = *i;
				
				cal = new CCalendrier();
				cal->id = atoi(row["id_calendrier"]);
	
cal->decode(TYPE_JSEM,(char*)row["jsem"].c_str());
				cal->decode(TYPE_MOIS,
(char*)row["mois"].c_str());
				cal->decode(TYPE_JOUR,
(char*)row["jour"].c_str());
				cal->decode(TYPE_HEURE,
(char*)row["heure"].c_str());
				cal->decode(TYPE_MINUTE,
(char*)row["minute"].c_str());
				cal->decode(TYPE_SECONDE,
(char*)row["seconde"].c_str());
				
				if(!row["time_deb"].is_null() &&
!row["time_fin"].is_null() )
				{
	
cal->add_timeperiode((char*)row["time_deb"].c_str(),(char*)row["time_fin"].c
_str());
					
				}
				
				ite = ListeCal.searchPos(cal->id);
	
				if(ite == ListeCal.ListeCDC.end())
					ListeCal.ListeCDC.push_back(*cal);
				else
				{
					ite = ListeCal.searchPos(cal->id);
					ListeCal.ListeCDC.insert(ite,*cal);
					ite = ListeCal.searchPos(cal->id);
					ListeCal.ListeCDC.erase(ite);

				}
				
			}	
			query.clear();
		
		}
		//cerr << "nbre Calendrier : "<< nb_result << endl;
	} catch ( const mysqlpp::BadQuery& er){ 
		cerr << "Error: " << er.what() << endl;
		strlog ="GetTelephone() - Error: ";
		strlog += er.what() ;
		r->LogRoomSend((char*) strlog.c_str());
	} catch (const mysqlpp::BadConversion& er) {
		cerr << "Error: convertion "<< er.what()<< endl;
		strlog ="GetTelephone() - Error convertion : ";
		strlog += er.what() ;
		r->LogRoomSend((char*) strlog.c_str());
	}	
	catch (const mysqlpp::Exception& er) {
		cerr << "Error: hummmm : \n" << er.what() << endl;
		strlog ="GetTelephone() - Error hummmm : ";
		strlog += er.what() ;
		r->LogRoomSend((char*) strlog.c_str());
	}	

}

But after all exception the program abort.


terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::substr
IOT Trap
Abort(coredump)

Please help-me.

Hervé



Thread
probleme with exeptionsMaarten Schrijvers2 Oct
  • Re: probleme with exeptionsHai Nguyen2 Oct