Menu

#12 connection hangs when database dies

open
nobody
None
5
2003-03-26
2003-03-26
No

I am using the driver version 65 for the MySQL database.
When the database is shudown, but the application is
still alive, the connection hangs as it cant write /
read from the socket.
So one cant event invoke Connection.Open() as the state
is already set to Open.
Also, the connection.close() returns an exception, as
for the connection to close the driver sends a
DBCmd.Quit to the database server, which again throws
an exception.

If you can change the Connection.Close() to the
following snipppet, it will close the socket and change
the connection state, so that the connection can be
reopened when the database comes back without
restarting the application

File: MySQLClient/Connection.cs
public void Close()
{
// this shouldn't happen, but it is!
if (m_state == ConnectionState.Closed) return;
try
{
m_Driver.SendCommand( DBCmd.QUIT, null );
}
catch(Exception e)
{
e.ToString();
}//catch
try
{
m_Driver.Close();
}
catch(Exception e)
{
e.ToString();
}//catch

        m\_state = ConnectionState.Closed;
    \}

Hope the snippet helped.

regards,
Ishpal.

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.