科技行者

行者学院 转型私董会 科技行者专题报道 网红大战科技行者

知识库

知识库 安全导航

至顶网软件频道基础软件探索MySql.Data.dll

探索MySql.Data.dll

  • 扫一扫
    分享文章到微信

  • 扫一扫
    关注官方公众号
    至顶头条

MySql.Data.dll是.Net访问MySQL数据库的一个驱动,完全ADO.NET数据访问模式,由MySQL官方提供,有多个版本可选择。

作者:chy710 来源:IT专家网 2008年4月13日

关键字: data SQL my net Windows

  • 评论
  • 分享微博
  • 分享邮件
MySql.Data.dll是.Net访问MySQL数据库的一个驱动,完全ADO.NET数据访问模式,由MySQL官方提供,有多个版本可选择。

  最早使用的环境:.Net2.0+MySQL5.x+MySQL.data.dll 1.0.7,感觉似乎很稳定,一直没什么大问题。随着系统升级,尝试更新MySql.Data.dll版本(1.07版本官方早不提供下载了,现在最新版本分别是:1.0.10,5.0.8,5.1.4),问题出现了,经常会出现异常  

以下是引用片段:
The timeout period elapsed prior to completion of the operation or the server is not responding

  在业务逻辑及数据不变的情况下,仅更换MySql.Data.dll就出现异常让我费尽了心思。

  其实在SQLServer中有时也出现此问题,有人建议设置ConnectionTimeout和CommandTimeout时长来解决,MySql.Data.dll中也有这些属性,下载了MySql.Data.dll的源码,看了下,似乎发现了一线希望,在1.07版本的源码中ConnectionString.cs类中有

以下是引用片段:
[Category("Connection")]
        [Description("Number of seconds to wait for the connection to succeed")]
        [DefaultValue(15)]
        public int ConnectionTimeout
        {
            get { return GetInt("connect timeout"); }
        }

  只读属性,默认值为15秒,可以在连接字符串设置。

  在command.cs类中有

以下是引用片段:
[Category("Misc")]
        [Description("Time to wait for command to execute")]
        public int CommandTimeout
        {
            // TODO: support this
            get  { return 0; }
            set  { if (value != 0) throw new NotSupportedException(); }
        }

  默认值是0,表示没时长限制?猜的。对其赋值如不为0,则抛出异常,也就是说赋值只能为0,那也就是该属性只读了?其值不可改变。

  再来看新版本的,在5.0.8的源码中MySqlConnectionStringBuilder.cs类中有

以下是引用片段:
[Category("Connection")]
        [DisplayName("Connect Timeout")]
        [Description("The length of time (in seconds) to wait for a connection " +
             "to the server before terminating the attempt and generating an error.")]
        [DefaultValue(15)]
        [RefreshProperties(RefreshProperties.All)]
        public uint ConnectionTimeout
        {
            get { return connectionTimeout; }
            set
            {
                SetValue("Connect Timeout", value);
                connectionTimeout = value;
            }
        }

  属性可读写,默认值为15秒。

  在command.cs类中有

以下是引用片段:
[Category("Misc")]
        [Description("Time to wait for command to execute")]
        [DefaultValue(30)]
        public override int CommandTimeout
        {
            get { return commandTimeout; }
            set { commandTimeout = value; }
        }

  属性可读写,默认值为30秒(这些默认值感觉跟SQLServer一样的),这一点跟1.0.7就不同了。1.0.7为只读且值为0。

    • 评论
    • 分享微博
    • 分享邮件
    邮件订阅

    如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。

    重磅专题
    往期文章
    最新文章