void CConnectionPoolManager::exec( CDbStatusItem* pDbStatusItem, const SQLStatement& rSqlObj )
{

	IDbConnectionPool* pDBConPoolGet = NULL;
	unsigned long retry = 0;
	bool execOk = false;
	IQueryAdapter* pQueryAdapter = NULL;

	//check pool
	if (false == _ConnectionExists(pDbStatusItem))
	{
		LOG_DEBUG<<" "<<"connectionStr="<<pDbStatusItem->getConnectionString()
			<<" "<<"not in DB Connection Pool";

		return;
	}

	pDBConPoolGet = _GetConnectionPool(pDbStatusItem);

	LOG_DEBUG<<"begin execute the SQL statement";

	try
	{
		pDBConPoolGet->exec(rSqlObj, pQueryAdapter, false, 0);

		if ( NULL != pQueryAdapter )
		{
			LOG_ERROR<< "execute none query command should not return query";
			cleanQuery( pDbStatusItem, pQueryAdapter );
		}

		if (NULL != pQueryAdapter)
		{
			LOG_ERROR<<"query should be null";
		}
		execOk = true;
	}
	catch(...)
	{
		LOG_DEBUG<<"Fail execute the SQL statement";

		if ( NULL != pQueryAdapter )
		{
			cleanQuery( pDbStatusItem, pQueryAdapter );
		}

		pQueryAdapter = NULL;
	}


	LOG_DEBUG<<"End execute the SQL statement";
}
Esempio n. 2
0
void QgsServerParameters::load( const QUrlQuery &query )
{
  // clean query string first
  QUrlQuery cleanQuery( query );
  cleanQuery.setQuery( query.query().replace( '+', QStringLiteral( "%20" ) ) );

  // load parameters
  for ( const auto &item : cleanQuery.queryItems( QUrl::FullyDecoded ) )
  {
    const QgsServerParameter::Name name = QgsServerParameter::name( item.first );
    if ( name >= 0 )
    {
      mParameters[name].mValue = item.second;
      if ( ! mParameters[name].isValid() )
      {
        mParameters[name].raiseError();
      }
    }
    else if ( item.first.compare( QLatin1String( "VERSION" ) ) == 0 )
    {
      const QgsServerParameter::Name name = QgsServerParameter::VERSION_SERVICE;
      mParameters[name].mValue = item.second;
      if ( ! mParameters[name].isValid() )
      {
        mParameters[name].raiseError();
      }
    }
    else if ( ! loadParameter( item.first, item.second ) )
    {
      mUnmanagedParameters[item.first.toUpper()] = item.second;
    }
  }
}
IQueryAdapter* CConnectionPoolManager::exec( CDbStatusItem* pDbStatusItem, const SQLStatement& rSqlObj, int numRows )
{

	IDbConnectionPool* pDBConPoolGet = NULL;
	int prefetch = numRows;
	unsigned long retry = 0;
	bool execOk = false;
	unsigned long nTrytimes = EXEC_NUM_RETRIES;//3
	IQueryAdapter* pQueryAdapter = NULL;

	//check pool
	if (false == _ConnectionExists(pDbStatusItem))
	{
		LOG_DEBUG<<" "<<"connectionStr="<<pDbStatusItem->getConnectionString()
			<<" "<<"not in DB Connection Pool";


		return pQueryAdapter;
	}

	pDBConPoolGet = _GetConnectionPool(pDbStatusItem);

	LOG_DEBUG<<"begin execute the SQL statement";

	// Execute the statement.
	try
	{
		pDBConPoolGet->exec(rSqlObj, pQueryAdapter, true, prefetch);
		execOk = true;
	}
	catch(...)
	{
		if ( NULL != pQueryAdapter )
		{
			cleanQuery( pDbStatusItem, pQueryAdapter );
		}
		LOG_DEBUG<<"Fail execute the SQL statement";
		execOk = false;
	}

	LOG_DEBUG<<"End execute the SQL statement";

	return pQueryAdapter;
}