Skip to content

Poco::Data::Session::reconnect threw an exception #3129

@lrh450330

Description

@lrh450330

I use the ODBC database interface code as follows:

std::string dbConnString= Poco::format("DRIVER=%s;UID=%s;PWD=%s;DATABASE=%s;SERVER=%s;PORT=%s;", driver, user, pwd, db, serv, port);
std::shared_ptr<Poco::Data::SessionPool > m_pSessionPool = std::make_sharedPoco::Data::SessionPool(Poco::Data::ODBC::Connector::KEY, dbConnString);

Poco::Data::Session trackSess(m_pSessionPool->get());
......
trackSess << ... << Poco::Data::Keywords::now;
......

An error is reported after running the program for a period of time: not connected to data source.Next, perform the reconnection process:
trackSess.reconnect();
......

The program threw an exception. Because reconnect() call close() and set _pHolder = 0,then open() will throw the wrong exception.If there is an error in a connection in the database connection pool, such as network exception, what should I do to connect to the database again

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions