zoukankan      html  css  js  c++  java
  • Mysql System.Exception: 错误:Fatal error encountered during command execution.

    折磨死人的报错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: 未将对象引用设置到对象的实例。

    这异常提示也太难猜了

  • 相关阅读:
    Redis命令——小白学习 Redis 数据库日记(2017-06-13)
    Buses(形容城市公车交通情况)
    Things you need to prepare before going to airport
    bathroom words
    this指针
    友元
    成员对象和封闭类
    静态成员变量和静态成员函数、 常量对象和常量成员函数
    C++类
    shell选择语句、循环语句
  • 原文地址:https://www.cnblogs.com/jiangling/p/3685558.html
Copyright © 2011-2022 走看看