List:MySQL++« Previous MessageNext Message »
From:bsingh Date:September 19 2008 6:04pm
Subject:"commands out of sync,you can't run this command now"
View as plain text  
Hi All & Warren,

My Application is polling DB and calls a stored procedure in loop to get new records from
DB. I see that first call goes fine and in second  (onwards) , it  throws exception. The
error description is "commands out of sync,you can't run this command now". Can  anyone
help me please ?

Here is pseudo code ...

------------------------------  global connection --------------------------------
m_DBReadCon.set_option(new mysqlpp::MultiStatementsOption(true));
if(m_DBReadCon.connect(m_pCommon->getDBName().c_str(),
m_pCommon->getDBServerName().c_str(),m_pCommon->getDBUser().c_str(),
m_pCommon->getDBPassword().c_str()) == true)
 {
       m_bDBConnection = true;
       LOG_INFO(logger,"DBManager:DB Connection SUCCESS");
  }else{
       LOG_ERROR(logger,"DBManager:DB Connection failed " << m_DBReadCon.error());
       return -1;
  }
-------------------------------------------------------------------------------------------------------------

Code snippet from looping thread 

        mysqlpp::Query sqlquery = m_DBReadCon.query();
        mysqlpp::StoreQueryResult sqlresults;
        sqlquery << "call spGetNewRecords(" << AppID << ",1);"; 

        if (sqlresults = sqlquery.store()) {
            if(sqlresults.num_rows() <= 0){
                LOG_INFO(logger,"DBManager: No records found to execute from Database");
                return SUCCESS;
            }
            for (size_t i = 0; i < sqlresults.num_rows(); ++i) {
                DB_RECORD *pData = new DB_RECORD;
                pData->ListID              = sqlresults[i]["ListID"];
                pData->Phone              = sqlresults[i]["Phone"];
                pData->PhoneType      = sqlresults[i]["PhoneType"];
                LOG_INFO(logger,"NewRecord: ListID: " << pData->Phone <<
",PhoneType: " <<  pData->PhoneType );
                //  push record in Q now 
                PushRecordInReadQ(pData,sizeof(pData));
            }
        }
        else {
            LOG_ERROR(logger,"DBManager::Failed to get item list: " <<
sqlquery.error() );
            RetVal = -1;
        }
        return RetVal;
    }
    catch (const mysqlpp::BadOption& err) {
        LOG_ERROR(logger,"DBManager::Query error: " << err.what() );
        RetVal = -1;
    }
    catch (const mysqlpp::ConnectionFailed& err) {
        LOG_ERROR(logger,"DBManager::Failed to connect to database server: " <<
err.what() );
        RetVal = -1;
    }
    catch (const mysqlpp::Exception& err) {
        // Catch-all for any other MySQL++ exceptions
        LOG_ERROR(logger,"DBManager:Unknown Exception : " << err.what() );
        RetVal = -1;
    }
    catch(...){
        LOG_ERROR(logger,"DBManager:Exception occured while looking for new records");
        RetVal = -1;
    }


Thanks.
Thread
"commands out of sync,you can't run this command now"bsingh19 Sep
  • RE: "commands out of sync,you can't run this command now"Jim Wallace19 Sep
  • Re: "commands out of sync,you can't run this command now"Jim Graf19 Sep
Re: "commands out of sync,you can't run this command now"Jim Graf20 Sep
Re: "commands out of sync,you can't run this command now"Jim Graf21 Sep