Browse Source

Improve reconnection behavior

JDierkse 10 tháng trước cách đây
mục cha
commit
7b7dfa067b
1 tập tin đã thay đổi với 12 bổ sung0 xóa
  1. 12 0
      MySQL/MySQLClientImpl.cpp

+ 12 - 0
MySQL/MySQLClientImpl.cpp

@@ -72,9 +72,21 @@ void MySQLClientImpl::Execute(const std::string& query)
 	if (!m_connected)
 	{
 		if (m_automaticReconnect)
+		{
 			InternalConnect();
+			if (!m_connected)
+			{
+				std::stringstream ss;
+				ss << "MySQLClientImpl::Execute() - Error: Reconnect failed" << std::endl;
+				ss << "Query: " << query << std::endl;
+				Logging::Log(Logging::Severity::Error, ss.str());
+				return;
+			}
+		}
 		else
+		{
 			throw std::runtime_error("MySQLClientImpl::ExecuteQuery() - Not connected to a Database Server");
+		}
 	}
 
 	try