折磨死人的报错Fatal error encountered during command execution. 服务使用的是长连接
private MySqlConnection _Conn;
public MySqlHelper(String dbConnectString)
{
_DataBaseConnectString = dbConnectString;
_Conn = new MySqlConnection(dbConnectString);
_Conn.Open();
}
private void ExecuteNonQuery(string connectString, CommandType cmdType, string cmdText, params MySqlParameter[] commandParameters)
{
MySqlCommand cmd = new MySqlCommand();
PrepareCommand(cmd, _Conn, cmdType, cmdText, commandParameters);
try
{
cmd.ExecuteNonQuery();
}
catch (MySqlException e)
{
throw new Exception(String.Format("错误:{0}
出错Sql:{1}", e.Message, cmdText));
}
cmd.Parameters.Clear();
}
构造函数就初始化了_Conn; Mysql 服务器配置wait_timeout 时间为120S,那么在主系统休眠超过120秒之后,再执行数据操作就报上面的错误,后续就是System.NullReferenceException: 未将对象引用设置到对象的实例。
这异常提示也太难猜了