Commit b402dca5 authored by Marco De Marco's avatar Marco De Marco
Browse files

Reconnect added to DBManager class

parent 9294f98d
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ void DBManager::connect() throw(soci::soci_error)
    connection << " password=" << m_configuration_sp->getDatabasePassword();

    #ifdef VERBOSE_DEBUG
        INFO_STREAM << "CONNECTION: " << connection.str() << endl;
        INFO_STREAM << "DBManager::connect(): " << connection.str() << endl;
    #endif

    unsigned int connectionNumber = m_configuration_sp->getDatabaseConnectionNumber();
@@ -96,6 +96,9 @@ DBManager::InformationList DBManager::retrieveInformation(std::string schema,

    soci::session session(*m_connectionPool_sp);

    if(session.get_backend() == NULL)
        session.reconnect();

    soci::rowset<InformationTuple> rows = (session.prepare << "select "
        "column_name, column_type, is_nullable from information_schema.columns "
        "where table_schema like :schema and table_name like :table",
@@ -125,6 +128,9 @@ DBManager::RowsetSP DBManager::retrieveNewTuples(std::string schema,

    soci::session session(*m_connectionPool_sp);

    if(session.get_backend() == NULL)
        session.reconnect();

    //@workaround: this does not work: timestamp parameter not passed
//    RowsetSP rows(new soci::rowset<soci::row>((session.prepare << "select * from "
//        << schema << "." << table << " where update_time > :timestamp "
+2 −2
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ public:
    virtual void disconnect();

//------------------------------------------------------------------------------
//  [Public] Retrieve information schema method
//  [Public] Retrieve from information schema method
//------------------------------------------------------------------------------
    typedef boost::tuple< boost::optional<std::string>, boost::optional<std::string>,
        boost::optional<std::string> > InformationTuple;
@@ -73,7 +73,7 @@ public:
        std::string) throw(soci::soci_error);

//------------------------------------------------------------------------------
//  [Public] Search new tuple method
//  [Public] Retrieve new tuple method
//------------------------------------------------------------------------------
    typedef boost::shared_ptr< soci::rowset<soci::row> > RowsetSP;