Skip to content

Poco::Data::Session::reconnect throw Connection in use #3812

@xakod

Description

@xakod

Hello, first of all, I found the same issues #2994 and #3129 but they are closed
Here is a bit pseudo code, don't forget try catch blocks and etc.

std::string connection;
...
auto session=Poco::Data::Session("ODBC", connection);


if (Session.isConnected())
  std::cout<<"connected"<<std::endl; // connected
/// wait some time
/// you can wait more or just drop your network connection 
if (Session.isConnected())
  std::cout<<"connected"<<std::endl; // still connected!!
/// Try to execute any query
/// For example
Statement.execute(...);
/// throws StatementException() from ctor Preparator(const StatementHandle& rStmt,
///	const std::string& statement,
///	std::size_t maxFieldSize,
///	DataExtraction dataExtraction);

/// Now your session connection becames not connected
/// You can try
if (!Session.isConnected())
  std::cout<<"not connected"<<std::endl; // not connected

/// Establish your network connection again
if (!Session.isConnected())
  std::cout<<"not connected"<<std::endl; // not connected
/// try to reconnect
Session.reconnect();
/// reconnect internally calls close and then open
/// open() couldnt open connection and throws exception
Connection:Not applicable
Server:Not applicable
===========================
ODBC Diagnostic record #1:
===========================
SQLSTATE = 08002
Native Error Code = 0
[Microsoft][ODBC Driver Manager] Connection in use

So we cannot reconnect to current session. The only way is to create new session.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions