DbLib: Reconnect if connection is lost
This commit is contained in:
parent
cc2b107649
commit
66799b60f8
|
@ -348,6 +348,10 @@ bool DATABASE_CONNECTION::SelectOne( const std::string& aTable,
|
|||
m_lastError = e.what();
|
||||
wxLogTrace( traceDatabase, wxT( "Exception while preparing statement for SelectOne: %s" ),
|
||||
m_lastError );
|
||||
|
||||
// Exception may be due to a connection error; nanodbc won't auto-reconnect
|
||||
m_conn->disconnect();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -365,6 +369,10 @@ bool DATABASE_CONNECTION::SelectOne( const std::string& aTable,
|
|||
m_lastError = e.what();
|
||||
wxLogTrace( traceDatabase, wxT( "Exception while executing statement for SelectOne: %s" ),
|
||||
m_lastError );
|
||||
|
||||
// Exception may be due to a connection error; nanodbc won't auto-reconnect
|
||||
m_conn->disconnect();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -434,6 +442,10 @@ bool DATABASE_CONNECTION::SelectAll( const std::string& aTable, std::vector<ROW>
|
|||
m_lastError = e.what();
|
||||
wxLogTrace( traceDatabase, wxT( "Exception while preparing query for SelectAll: %s" ),
|
||||
m_lastError );
|
||||
|
||||
// Exception may be due to a connection error; nanodbc won't auto-reconnect
|
||||
m_conn->disconnect();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -448,6 +460,10 @@ bool DATABASE_CONNECTION::SelectAll( const std::string& aTable, std::vector<ROW>
|
|||
m_lastError = e.what();
|
||||
wxLogTrace( traceDatabase, wxT( "Exception while executing query for SelectAll: %s" ),
|
||||
m_lastError );
|
||||
|
||||
// Exception may be due to a connection error; nanodbc won't auto-reconnect
|
||||
m_conn->disconnect();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -251,6 +251,9 @@ void SCH_DATABASE_PLUGIN::ensureConnection()
|
|||
{
|
||||
wxCHECK_RET( m_settings, "Call ensureSettings before ensureConnection!" );
|
||||
|
||||
if( m_conn && !m_conn->IsConnected() )
|
||||
m_conn.reset();
|
||||
|
||||
if( !m_conn )
|
||||
{
|
||||
if( m_settings->m_Source.connection_string.empty() )
|
||||
|
|
Loading…
Reference in New Issue