<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-35  評(píng)論-33  文章-0  trackbacks-0
      2017年8月25日

          已經(jīng)一個(gè)多月沒(méi)有寫(xiě)東西了,不過(guò)最近確實(shí)很忙。前兩天在線上碰到一個(gè)C3P0的鏈接死鎖的異常,話說(shuō)這個(gè)上古神物 ,我已經(jīng)是很久不碰了。先貼異常



    異常截圖

    "apparent deadlocks":名詞解釋是說(shuō)c3p0拿到鏈接之后,最終使用之后沒(méi)有返回到pool,導(dǎo)致死鏈檢測(cè)失敗。經(jīng)過(guò)在stack Overflow檢索,https://stackoverflow.com/questions/3730844/c3p0-apparent-deadlock-when-the-threads-are-all-empty.發(fā)現(xiàn)增加一個(gè)statementCacheNumDeferredCloseThreads該參數(shù)的定義,就可以避免這個(gè)問(wèn)題。

    經(jīng)過(guò)查看官方文檔:http://www.mchange.com/projects/c3p0/#statementCacheNumDeferredCloseThreads



    解釋:如果把該值設(shè)為超過(guò)1,statement的緩存就會(huì)自動(dòng)跟蹤當(dāng)前可用的connections,如果沒(méi)有再用,就會(huì)自動(dòng)銷毀掉。如果需要另外的線程來(lái)專門(mén)銷毀緩存的statement,則還需要設(shè)置maxStatements與maxStatementsPerConnection。

    再貼一個(gè)官方的說(shuō)明:

    Configuring Statement Pooling

    c3p0 implements transparent PreparedStatement pooling as defined by the JDBC spec. Under some circumstances, statement pooling can dramatically improve application performance. Under other circumstances, the overhead of statement pooling can slightly harm performance. Whether and how much statement pooling will help depends on how much parsing, planning, and optimizing of queries your databases does when the statements are prepared. Databases (and JDBC drivers) vary widely in this respect. It's a good idea to benchmark your application with and without statement pooling to see if and how much it helps.

    You configure statement pooling in c3p0 via the following configuration parameters:

    maxStatements

    maxStatementsPerConnection

    statementCacheNumDeferredCloseThreads

    maxStatementsis JDBC's standard parameter for controlling statement pooling.maxStatementsdefines the total numberPreparedStatementsa DataSource will cache. The pool will destroy the least-recently-used PreparedStatement when it hits this limit. This sounds simple, but it's actually a strange approach, because cached statements conceptually belong to individual Connections; they are not global resources. To figure out a size formaxStatementsthat does not "churn" cached statements, you need to consider the number offrequently usedPreparedStatements in your application,and multiply that by the number of Connections you expect in the pool (maxPoolSizein a busy application).

    maxStatementsPerConnectionis a non-standard configuration parameter that makes a bit more sense conceptually. It defines how many statements each pooled Connection is allowed to own. You can set this to a bit more than the number ofPreparedStatementsyour applicationfrequentlyuses, to avoid churning.

    If either of these parameters are greater than zero, statement pooling will be enabled. If both parameters are greater than zero, both limits will be enforced. If only one is greater than zero, statement pooling will be enabled, but only one limit will be enforced.

    大概意思就是這兩個(gè),有一個(gè)值如果大于0,c3p0的statement pool就會(huì)發(fā)生作用。

    以上所有的配置都是基于c3p0的最新版本。PS一下,還是2015年的JAR。



    通過(guò)引入最新的C3P0包,另外增加了兩段配置,線上觀察兩天,問(wèn)題解決。



    最后打個(gè)小廣告,JAVA世界最快的JDBC連接池,非HikariCP莫屬。已經(jīng)甩c3p0好幾個(gè)街角,有圖有真像。



    posted @ 2017-11-10 15:25 alexcai 閱讀(1800) | 評(píng)論 (0)編輯 收藏
         摘要: 在word的處理之中,文字,各種類型的圖片,最復(fù)雜的公式,之前編寫(xiě)的API基本都覆蓋了。不過(guò),昨天在做一個(gè)文檔測(cè)試時(shí),發(fā)現(xiàn)表格沒(méi)有能很好的處理。  閱讀全文
    posted @ 2017-08-25 15:54 alexcai 閱讀(757) | 評(píng)論 (0)編輯 收藏
    主站蜘蛛池模板: 日韩免费的视频在线观看香蕉| 日本zzzzwww大片免费| 国产福利免费视频| 99视频在线免费看| 四虎亚洲国产成人久久精品| 亚洲va中文字幕无码久久不卡 | 麻豆国产VA免费精品高清在线| 伊人久久大香线蕉亚洲五月天| 香蕉大伊亚洲人在线观看| 中文字幕无码一区二区免费| 免费观看午夜在线欧差毛片| 亚洲视频一区二区三区四区| 久久久久久AV无码免费网站 | 亚洲18在线天美| 韩日电影在线播放免费版| 女人18毛片水真多免费看| 日木av无码专区亚洲av毛片| 国产一级a毛一级a看免费视频| 免费无遮挡无码永久在线观看视频| 亚洲国产精品一区二区成人片国内| 老子影院午夜伦不卡亚洲| 男人的好免费观看在线视频| 亚洲综合在线视频| 青娱乐免费在线视频| 亚洲一级二级三级不卡| 成人女人A级毛片免费软件| 亚洲高清不卡视频| 免费国产黄网站在线观看可以下载| 亚洲乱码中文字幕小综合| 37pao成人国产永久免费视频| 亚洲成a人片77777老司机| 男女一进一出抽搐免费视频 | 亚洲AV无码久久精品成人| 久久笫一福利免费导航| 亚洲av无码一区二区三区四区| 国产成人无码免费看视频软件 | 免费国产a国产片高清| 成人无码精品1区2区3区免费看| 中文字幕亚洲综合久久2| 国产美女无遮挡免费网站| 精品亚洲国产成人av|