-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Description
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 exceptionConnection: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.
Reactions are currently unavailable