mirror of
https://github.com/pocoproject/poco.git
synced 2025-11-25 06:36:37 +01:00
Reset connection when a session is returned to the SessionPool
This commit is contained in:
@@ -65,6 +65,9 @@ public:
|
||||
void rollback();
|
||||
/// Rollback transaction
|
||||
|
||||
void resetConnection();
|
||||
/// Reset connection with dababase and clears session state, but without disconnecting
|
||||
|
||||
operator MYSQL* ();
|
||||
|
||||
private:
|
||||
|
||||
@@ -66,6 +66,9 @@ public:
|
||||
|
||||
void close();
|
||||
/// Closes the connection.
|
||||
|
||||
void resetConnection();
|
||||
/// Reset connection with dababase and clears session state, but without disconnecting
|
||||
|
||||
bool isConnected() const;
|
||||
/// Returns true if connected, false otherwise.
|
||||
|
||||
@@ -176,4 +176,11 @@ void SessionHandle::rollback()
|
||||
}
|
||||
|
||||
|
||||
void SessionHandle::resetConnection()
|
||||
{
|
||||
if (mysql_reset_connection(_pHandle) != 0)
|
||||
throw TransactionException("Reset connection failed.", _pHandle);
|
||||
}
|
||||
|
||||
|
||||
}}} // Poco::Data::MySQL
|
||||
|
||||
@@ -257,6 +257,13 @@ bool SessionImpl::hasTransactionIsolation(Poco::UInt32 ti) const
|
||||
}
|
||||
|
||||
|
||||
void SessionImpl::resetConnection()
|
||||
{
|
||||
if (_connected)
|
||||
_handle.resetConnection();
|
||||
}
|
||||
|
||||
|
||||
void SessionImpl::close()
|
||||
{
|
||||
if (_connected)
|
||||
|
||||
Reference in New Issue
Block a user