探索MySql.Data.dll
生活随笔
收集整理的這篇文章主要介紹了
探索MySql.Data.dll
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
ADO.NET Driver for MySQL?
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。
我感覺前面提到的Timeout異常跟這里有很大關系,準備測試下.......
?
PS:希望能在園子里找些用MySQL的朋友,有問題可以一起探討,在社區建了個小組:?.Net+MySQL 本文轉自chy710博客園博客,原文鏈接:http://www.cnblogs.com/chy710/archive/2007/12/30/1020801.html,如需轉載請自行聯系原作者
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。
我感覺前面提到的Timeout異常跟這里有很大關系,準備測試下.......
?
PS:希望能在園子里找些用MySQL的朋友,有問題可以一起探討,在社區建了個小組:?.Net+MySQL 本文轉自chy710博客園博客,原文鏈接:http://www.cnblogs.com/chy710/archive/2007/12/30/1020801.html,如需轉載請自行聯系原作者
總結
以上是生活随笔為你收集整理的探索MySql.Data.dll的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C语言数据结构学习用单元测试
- 下一篇: Spark使用总结与分享