AbandonedObjectPool 的相關屬性

來源:互聯網
上載者:User
AbandonedObjectPool is used什麼情況?

AbandonedObjectPool is used (org.apache.commons.dbcp.AbandonedObjectPool@7c12a1) 
   LogAbandoned: false 
   RemoveAbandoned: true 

   RemoveAbandonedTimeout: 300

將dataSource的配置 removeAbandoned = true去掉即可。 
詳解: 

引用在配置時,主要難以理解的主要有:removeAbandoned 、logAbandoned、removeAbandonedTimeout、maxWait這四個參數,設定了rmoveAbandoned=true 那麼在getNumActive()快要到getMaxActive()的時候,系統會進行無效的Connection的回收,回收的 Connection為removeAbandonedTimeout(預設300秒)中設定的秒數後沒有使用的Connection,啟用回收機制好像是getNumActive()=getMaxActive()-2。 有點忘了。 
  logAbandoned=true的話,將會在回收事件後,在log中列印出回收Connection的錯誤資訊,包括在哪個地方用了Connection卻忘記關閉了,在調試的時候很有用。 
  在這裡私人建議maxWait的時間不要設得太長,maxWait如果設定太長那麼用戶端會等待很久才激發回收事件。 
  以下是我的配置的properties檔案: 
#串連設定 
jdbc.driverClassName=oracle.jdbc.driver.OracleDriver 
jdbc.url=jdbc:oracle:thin:@127.0.0.1:1521:DBSERVER 
jdbc.username=user 
jdbc.password=pass 

#<!-- 初始化串連 --> 
dataSource.initialSize=10 

#<!-- 最大空閑串連 --> 
dataSource.maxIdle=20 

#<!-- 最小空閑串連 --> 
dataSource.minIdle=5 

#最大串連數量 
dataSource.maxActive=50 

#是否在自動回收逾時串連的時候列印串連的逾時錯誤 
dataSource.logAbandoned=true 

#是否自動回收逾時串連 
dataSource.removeAbandoned=true 

#逾時時間(以秒數為單位) 
dataSource.removeAbandonedTimeout=180 

#<!-- 逾時等待時間以毫秒為單位 6000毫秒/1000等於60秒 --> 
dataSource.maxWait=1000 轉載至:http://blog.csdn.net/demon_chin/article/details/7998610

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.