Installing Image Magick, Magick Wand, PHP, FreeType Mozilla, javascript and xml parsing.

.net mysql , and the unreliable connection state.

13 Nov 2006

I posted this as a bug on mysql... here it is again

Well, it seems to me that Connection.State is not reliably correct. If I stop
and start the mysql server, the state still reads as open, and throws
'connection reset' exceptions if i act on it.

So, I made a wrapper class, because the MysqlConnection class is sealed and I couldn't extend. Here it is for your benefit.

---------
/*
* User: bill@bigmojo.net
* Date: 9/12/2005
* Time: 11:16 AM
*
*/

using System; using System.Data;

using MySql.Data.MySqlClient;

namespace My.MySqlConnection {

/// /// Description of MySqlConnection. /// public class xmmsMySqlConnection:IDbConnection { private MySqlConnection _mysql = null;

public xmmsMySqlConnection() { _mysql = new MySqlConnection(); }

region IDbConnection Members

public void ChangeDatabase(string databaseName)

{

_mysql.ChangeDatabase(Database);

}

public IDbTransaction BeginTransaction(System.Data.IsolationLevel il)

{

return _mysql.BeginTransaction(il);

}

IDbTransaction System.Data.IDbConnection.BeginTransaction()

{

return _mysql.BeginTransaction();

}

/// /// This is why we have this class, return results of ping, more reliable. /// public System.Data.ConnectionState State

{

get

{

if ( _mysql != null && _mysql.State != ConnectionState.Closed && _mysql.Ping()){ return _mysql.State; }else{ return ConnectionState.Closed; }

}

}

public string ConnectionString

{

get

{

return _mysql.ConnectionString;

}

set

{

_mysql.ConnectionString = value;

}

}

public IDbCommand CreateCommand()

{

return _mysql.CreateCommand();

}

public void Open()

{

_mysql.Open();

}

public void Close()

{

_mysql.Close();

}

public string Database

{

get

{

return _mysql.Database;

}

}

public int ConnectionTimeout

{

get

{

return _mysql.ConnectionTimeout;

}

}

endregion

region IDisposable Members

public void Dispose()

{

_mysql.Dispose();

}

endregion

} } ----------------