2018-03-01

mysql服務端會默認檢查每個連接connection墩莫,一旦發(fā)現(xiàn)connection被閑置8小時(wait_timeout)逞敷,便會被斷開推捐。那我們可以在連接字符串中加入autoReconnect=true,同時配置下mybatis牛柒,一段時間又默認執(zhí)行下簡單的查詢皮壁,表明自己這個連接還活著,具體配置如下:
2015-03-26 09:40:25.956 ERROR GroupPrivController,119 -

Error querying database. Cause: org.apache.ibatis.transaction.TransactionException: Error configuring AutoCommit. Your driver may not support getAutoCommit() or setAutoCommit(). Requested setting: false. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 57,704,088 milliseconds ago. The last packet sent successfully to the server was 57,704,089 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.

The error may exist in mybatis/hiveDb.xml

The error may involve com.weibo.hamza.core.dao.DbDao.findByOwnerId

The error occurred while executing a query

Cause: org.apache.ibatis.transaction.TransactionException: Error configuring AutoCommit. Your driver may not support getAutoCommit() or setAutoCommit(). Requested setting: false. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 57,704,088 milliseconds ago. The last packet sent successfully to the server was 57,704,089 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.

org.apache.ibatis.exceptions.PersistenceException:

Error querying database. Cause: org.apache.ibatis.transaction.TransactionException: Error configuring AutoCommit. Your driver may not support getAutoCommit() or setAutoCommit(). Requested setting: false. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 57,704,088 milliseconds ago. The last packet sent successfully to the server was 57,704,089 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.

The error may exist in mybatis/hiveDb.xml

The error may involve com.weibo.hamza.core.dao.DbDao.findByOwnerId

The error occurred while executing a query

Cause: org.apache.ibatis.transaction.TransactionException: Error configuring AutoCommit. Your driver may not support getAutoCommit() or setAutoCommit(). Requested setting: false. Cause: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 57,704,088 milliseconds ago. The last packet sent successfully to the server was 57,704,089 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.

[html] view plain copy

<embed id="ZeroClipboardMovie_2" src="http://csdnimg.cn/public/highlighter/ZeroClipboard.swf" loop="false" menu="false" quality="best" bgcolor="#ffffff" name="ZeroClipboardMovie_2" allowscriptaccess="always" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="id=2&width=16&height=16" wmode="transparent" width="16" height="16" align="middle">

  1. <environments default="development">
  2. <environment id="development">
  3. <transactionManager type="jdbc"/>
  4. <dataSource type="POOLED">
  5. <property name="url" value="${cp.Url}"/>
  6. <property name="driver" value="${cp.DriverClassName}"/>
  7. <property name="username" value="${cp.Username}"/>
  8. <property name="password" value="${cp.Password}"/>
  9. <property name="poolPingEnabled" value="true"/>
  10. <property name="poolPingQuery" value="select 1"/>
  11. <property name="poolPingConnectionsNotUsedFor" value="3600000"/>
  12. </dataSource>
  13. </environment>
  14. </environments>
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末舌狗,一起剝皮案震驚了整個濱河市扔水,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌主届,老刑警劉巖,帶你破解...
    沈念sama閱讀 211,123評論 6 490
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件枫夺,死亡現(xiàn)場離奇詭異谈截,居然都是意外死亡,警方通過查閱死者的電腦和手機簸喂,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,031評論 2 384
  • 文/潘曉璐 我一進店門喻鳄,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人再菊,你說我怎么就攤上這事颜曾。” “怎么了泛豪?”我有些...
    開封第一講書人閱讀 156,723評論 0 345
  • 文/不壞的土叔 我叫張陵诡曙,是天一觀的道長。 經(jīng)常有香客問我价卤,道長,這世上最難降的妖魔是什么床嫌? 我笑而不...
    開封第一講書人閱讀 56,357評論 1 283
  • 正文 為了忘掉前任既鞠,我火速辦了婚禮盖文,結果婚禮上蚯姆,老公的妹妹穿的比我還像新娘洒敏。我一直安慰自己疙驾,他們只是感情好,可當我...
    茶點故事閱讀 65,412評論 5 384
  • 文/花漫 我一把揭開白布函荣。 她就那樣靜靜地躺著扳肛,像睡著了一般。 火紅的嫁衣襯著肌膚如雪挖息。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 49,760評論 1 289
  • 那天绪抛,我揣著相機與錄音幢码,去河邊找鬼尖飞。 笑死,一個胖子當著我的面吹牛葫松,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播咕娄,決...
    沈念sama閱讀 38,904評論 3 405
  • 文/蒼蘭香墨 我猛地睜開眼珊擂,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了圣贸?” 一聲冷哼從身側響起扛稽,我...
    開封第一講書人閱讀 37,672評論 0 266
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎用含,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體痴鳄,經(jīng)...
    沈念sama閱讀 44,118評論 1 303
  • 正文 獨居荒郊野嶺守林人離奇死亡缸夹,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 36,456評論 2 325
  • 正文 我和宋清朗相戀三年虽惭,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片趟妥。...
    茶點故事閱讀 38,599評論 1 340
  • 序言:一個原本活蹦亂跳的男人離奇死亡披摄,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出疚膊,到底是詐尸還是另有隱情寓盗,我是刑警寧澤,帶...
    沈念sama閱讀 34,264評論 4 328
  • 正文 年R本政府宣布基显,位于F島的核電站,受9級特大地震影響撩幽,放射性物質(zhì)發(fā)生泄漏箩艺。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 39,857評論 3 312
  • 文/蒙蒙 一榨惰、第九天 我趴在偏房一處隱蔽的房頂上張望静汤。 院中可真熱鬧居凶,春花似錦恢暖、人聲如沸狰右。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,731評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽谷暮。三九已至,卻和暖如春湿弦,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背蔬充。 一陣腳步聲響...
    開封第一講書人閱讀 31,956評論 1 264
  • 我被黑心中介騙來泰國打工饥漫, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留罗标,地道東北人。 一個月前我還...
    沈念sama閱讀 46,286評論 2 360
  • 正文 我出身青樓彻消,卻偏偏與公主長得像宙拉,于是被迫代替她去往敵國和親宾尚。 傳聞我的和親對象是個殘疾皇子鼓黔,可洞房花燭夜當晚...
    茶點故事閱讀 43,465評論 2 348

推薦閱讀更多精彩內(nèi)容