/////////////////////////////////////////////////////////////// // // CDatabaseManagerImpl::Disconnect // // // /////////////////////////////////////////////////////////////// bool CDatabaseManagerImpl::Disconnect ( uint hConnection ) { ClearLastErrorMessage (); // Check connection if ( !MapContains ( m_ConnectionTypeMap, hConnection ) ) { SetLastErrorMessage ( "Invalid connection" ); return false; } // Start disconnect CDbJobData* pJobData = m_JobQueue->AddCommand ( EJobCommand::DISCONNECT, hConnection, "" ); // Complete disconnect m_JobQueue->PollCommand ( pJobData, -1 ); // Check for problems if ( pJobData->result.status == EJobResult::FAIL ) { SetLastErrorMessage ( pJobData->result.strReason ); return false; } // Remove connection refs MapRemove ( m_ConnectionTypeMap, hConnection ); m_JobQueue->IgnoreConnectionResults ( hConnection ); return true; }
/////////////////////////////////////////////////////////////// // // CDatabaseManagerImpl::QueryPoll // // ulTimeout = 0 - No wait if not ready // ulTimeout > 0 - Wait(ms) if not ready // ulTimeout = -1 - Wait infinity+1 if not ready // /////////////////////////////////////////////////////////////// bool CDatabaseManagerImpl::QueryPoll ( CDbJobData* pJobData, uint ulTimeout ) { ClearLastErrorMessage (); if ( m_JobQueue->PollCommand ( pJobData, ulTimeout ) ) { if ( pJobData->result.status == EJobResult::FAIL ) SetLastErrorMessage ( pJobData->result.strReason ); return true; } return false; }
/////////////////////////////////////////////////////////////// // // CDatabaseManagerImpl::DatabaseConnect // // strType is one of the supported database types i.e. "sqlite" // /////////////////////////////////////////////////////////////// uint CDatabaseManagerImpl::Connect ( const SString& strType, const SString& strHost, const SString& strUsername, const SString& strPassword, const SString& strOptions ) { ClearLastErrorMessage (); SString strCombo = strType + "\1" + strHost + "\1" + strUsername + "\1" + strPassword + "\1" + strOptions; // Start connect CDbJobData* pJobData = m_JobQueue->AddCommand ( EJobCommand::CONNECT, 0, strCombo ); // Complete connect m_JobQueue->PollCommand ( pJobData, -1 ); // Check for problems if ( pJobData->result.status == EJobResult::FAIL ) { SetLastErrorMessage ( pJobData->result.strReason ); return INVALID_DB_HANDLE; } // Process result MapSet ( m_ConnectionTypeMap, pJobData->result.connectionHandle, strType ); return pJobData->result.connectionHandle; }