当前位置: 首页>>代码示例>>C++>>正文


C++ Database::EndTransaction方法代码示例

本文整理汇总了C++中Database::EndTransaction方法的典型用法代码示例。如果您正苦于以下问题:C++ Database::EndTransaction方法的具体用法?C++ Database::EndTransaction怎么用?C++ Database::EndTransaction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Database的用法示例。


在下文中一共展示了Database::EndTransaction方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: UpdateServiceVersion

void EventsWatcherDbOp::UpdateServiceVersion( const string& serviceName, const string& name, const string& version, const string& machine, const string& hash )
{
	Database* config = getConfig();
	
	ParametersVector params;
	
	DataParameterBase *serviceIdParam = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE );
	serviceIdParam->setDimension( serviceName.size() );
	serviceIdParam->setString( serviceName );
	params.push_back( serviceIdParam );
	
	DataParameterBase *nameParam = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE );
	nameParam->setDimension( name.size() );
	nameParam->setString( name );
	params.push_back( nameParam );	

	DataParameterBase *versionParam = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE );
	versionParam->setDimension( version.size() );
	versionParam->setString( version );
	params.push_back( versionParam );	

	DataParameterBase *machineParam = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE );
	machineParam->setDimension( machine.size() );
	machineParam->setString( machine );
	params.push_back( machineParam );	

	DataParameterBase *hashParam = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE );
	hashParam->setDimension( hash.size() );
	hashParam->setString( hash );
	params.push_back( hashParam );	
	
	try
	{
		config->BeginTransaction();
		config->ExecuteNonQuery( DataCommand::SP, "UPDATEVERSION", params );
	}
	catch( const std::exception& ex )
	{
		config->EndTransaction( TransactionType::ROLLBACK );
		TRACE( "Update service version failed [" << ex.what() << "] for [" << serviceName << "]" );
		
		throw;
	}
	catch( ... )
	{
		config->EndTransaction( TransactionType::ROLLBACK );
		TRACE( "Update service version failed [unknown reason] for [" << serviceName << "]" );

		throw;
	}

	config->EndTransaction( TransactionType::COMMIT );
}
开发者ID:FinTP,项目名称:fintp_eventswatcher,代码行数:53,代码来源:EventsWatcherDbOp.cpp

示例2: InsertEvent

void EventsWatcherDbOp::InsertEvent( const string& dadbuffer, const string& message )
{
	Database* data = getData();
	
	ParametersVector params;

	DataParameterBase *dadParam = m_DatabaseProvider->createParameter( DataType::LARGE_CHAR_TYPE );
	dadParam->setDimension( dadbuffer.length() );
	dadParam->setString( dadbuffer );
	dadParam->setName( "DAD_buffer" );
	params.push_back( dadParam );

	DataParameterBase *messageParam = m_DatabaseProvider->createParameter( DataType::LARGE_CHAR_TYPE );
	messageParam->setDimension( message.length() );
	messageParam->setName( "XML_buffer" );
	messageParam->setString( message );

	params.push_back( messageParam );

	DataParameterBase *paramReturnCode = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE, DataParameterBase::PARAM_OUT );
	DataParameterBase *paramReturnMessage = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE, DataParameterBase::PARAM_OUT );

	// return code from upload proc
	paramReturnCode->setDimension( 11 );
	params.push_back( paramReturnCode );
		
	// return message from upload proc
	paramReturnMessage->setDimension( 1024 );
	params.push_back( paramReturnMessage );

	data->BeginTransaction();
	try
	{
		data->ExecuteNonQueryCached( DataCommand::SP, "INSERTEVENTSBATCH", params );

		string returnCode = StringUtil::Trim( paramReturnCode->getString() );
		DEBUG( "Insert XML data return code : [" << returnCode << "]" );	 	
		if ( returnCode != "0" )
	 	{
	 		stringstream messageBuffer;
	  		messageBuffer << "Error inserting XML. Message : [" << paramReturnMessage->getString() << "]";
			TRACE( messageBuffer.str() );
			TRACE( "Original_buffer [" << message << "]" );

	 		throw runtime_error( messageBuffer.str() );
	 	}
	}
	catch( const std::exception& ex )
	{
		TRACE( "Insert event failed [" << ex.what() << "]" );
	}
	catch( ... )
	{
		TRACE( "Insert event failed [unknown reason]" );
	}

	data->EndTransaction( TransactionType::COMMIT );
	DEBUG2( "done" );
}
开发者ID:FinTP,项目名称:fintp_eventswatcher,代码行数:59,代码来源:EventsWatcherDbOp.cpp

示例3: UpdateServiceState

void EventsWatcherDbOp::UpdateServiceState( const long serviceId, const long newState, const string& sessionId )
{
	Database* config = getConfig();
	
	ParametersVector params;
	
	DataParameterBase *serviceIdParam = m_DatabaseProvider->createParameter( DataType::LONGINT_TYPE );
	serviceIdParam->setLong( serviceId );
	params.push_back( serviceIdParam );
	
	DataParameterBase *newStateParam = m_DatabaseProvider->createParameter( DataType::LONGINT_TYPE );
	newStateParam->setLong( newState );
	params.push_back( newStateParam );

	DataParameterBase *sessionIdParam = m_DatabaseProvider->createParameter( DataType::CHAR_TYPE );
	sessionIdParam->setDimension( sessionId.size() );
	sessionIdParam->setString( sessionId );
	params.push_back( sessionIdParam );	
	
	try
	{
		config->BeginTransaction();
		config->ExecuteNonQuery( DataCommand::SP, "UPDATESERVICESTATE", params );
	}
	catch( const std::exception& ex )
	{
		config->EndTransaction( TransactionType::ROLLBACK );
		TRACE( "Update service state failed [" << ex.what() << "] for [" << serviceId << "]" );
		
		throw;
	}
	catch( ... )
	{
		config->EndTransaction( TransactionType::ROLLBACK );
		TRACE( "Update service state failed [unknown reason] for [" << serviceId << "]" );

		throw;
	}

	config->EndTransaction( TransactionType::COMMIT );
}
开发者ID:FinTP,项目名称:fintp_eventswatcher,代码行数:41,代码来源:EventsWatcherDbOp.cpp

示例4: ReadServiceStatus

DataSet* EventsWatcherDbOp::ReadServiceStatus()
{
	Database* config = getConfig();

	config->BeginTransaction();

	DEBUG_GLOBAL( "Reading service status for all services" );
	DataSet *retStatus = config->ExecuteQuery( DataCommand::SP, "GetServiceState" );

	config->EndTransaction( TransactionType::ROLLBACK );

	return retStatus;
}
开发者ID:FinTP,项目名称:fintp_eventswatcher,代码行数:13,代码来源:EventsWatcherDbOp.cpp


注:本文中的Database::EndTransaction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。