锘??xml version="1.0" encoding="utf-8" standalone="yes"?>蜜芽亚洲av无码精品色午夜,国产精品V亚洲精品V日韩精品 ,亚洲资源在线观看http://m.tkk7.com/ashutc/category/48731.html娌堥槼姹傝亴錛坖ava3騫翠互涓婄粡楠岋級錛乤shutc@126.comzh-cnFri, 27 May 2011 07:59:25 GMTFri, 27 May 2011 07:59:25 GMT60c3p0璇︾粏閰嶇疆http://m.tkk7.com/ashutc/archive/2011/05/27/351184.html瑗跨摐瑗跨摐Fri, 27 May 2011 07:58:00 GMThttp://m.tkk7.com/ashutc/archive/2011/05/27/351184.htmlhttp://m.tkk7.com/ashutc/comments/351184.htmlhttp://m.tkk7.com/ashutc/archive/2011/05/27/351184.html#Feedback0http://m.tkk7.com/ashutc/comments/commentRss/351184.htmlhttp://m.tkk7.com/ashutc/services/trackbacks/351184.html
<c3p0-config>
<default-config>
<!--褰撹繛鎺ユ睜涓殑榪炴帴鑰楀敖鐨勬椂鍊檆3p0涓嬈″悓鏃惰幏鍙栫殑榪炴帴鏁般侱efault: 3 -->
<property name="acquireIncrement">3</property>

<!--瀹氫箟鍦ㄤ粠鏁版嵁搴撹幏鍙栨柊榪炴帴澶辮觸鍚庨噸澶嶅皾璇曠殑嬈℃暟銆侱efault: 30 -->
<property name="acquireRetryAttempts">30</property>

<!--涓ゆ榪炴帴涓棿闅旀椂闂達紝鍗曚綅姣銆侱efault: 1000 -->
<property name="acquireRetryDelay">1000</property>

<!--榪炴帴鍏抽棴鏃墮粯璁ゅ皢鎵鏈夋湭鎻愪氦鐨勬搷浣滃洖婊氥侱efault: false -->
<property name="autoCommitOnClose">false</property>

<!--c3p0灝嗗緩涓寮犲悕涓篢est鐨勭┖琛紝騫朵嬌鐢ㄥ叾鑷甫鐨勬煡璇㈣鍙ヨ繘琛屾祴璇曘傚鏋滃畾涔変簡榪欎釜鍙傛暟閭d箞
灞炴referredTestQuery灝嗚蹇界暐銆備綘涓嶈兘鍦ㄨ繖寮燭est琛ㄤ笂榪涜浠諱綍鎿嶄綔錛屽畠灝嗗彧渚沜3p0嫻嬭瘯
浣跨敤銆侱efault: null-->
<property name="automaticTestTable">Test</property>

<!--鑾峰彇榪炴帴澶辮觸灝嗕細寮曡搗鎵鏈夌瓑寰呰繛鎺ユ睜鏉ヨ幏鍙栬繛鎺ョ殑綰跨▼鎶涘嚭寮傚父銆備絾鏄暟鎹簮浠嶆湁鏁?
淇濈暀錛屽茍鍦ㄤ笅嬈¤皟鐢╣etConnection()鐨勬椂鍊欑戶緇皾璇曡幏鍙栬繛鎺ャ傚鏋滆涓簍rue錛岄偅涔堝湪灝濊瘯
鑾峰彇榪炴帴澶辮觸鍚庤鏁版嵁婧愬皢鐢蟲槑宸叉柇寮騫舵案涔呭叧闂侱efault: false-->
<property name="breakAfterAcquireFailure">false</property>

<!--褰撹繛鎺ユ睜鐢ㄥ畬鏃跺鎴風璋冪敤getConnection()鍚庣瓑寰呰幏鍙栨柊榪炴帴鐨勬椂闂達紝瓚呮椂鍚庡皢鎶涘嚭
SQLException,濡傝涓?鍒欐棤闄愭湡絳夊緟銆傚崟浣嶆縐掋侱efault: 0 -->
<property name="checkoutTimeout">100</property>

<!--閫氳繃瀹炵幇ConnectionTester鎴朡ueryConnectionTester鐨勭被鏉ユ祴璇曡繛鎺ャ傜被鍚嶉渶鍒跺畾鍏ㄨ礬寰勩?
Default: com.mchange.v2.c3p0.impl.DefaultConnectionTester-->
<property name="connectionTesterClassName"></property>

<!--鎸囧畾c3p0 libraries鐨勮礬寰勶紝濡傛灉錛堥氬父閮芥槸榪欐牱錛夊湪鏈湴鍗沖彲鑾峰緱閭d箞鏃犻渶璁劇疆錛岄粯璁ull鍗沖彲
Default: null-->
<property name="factoryClassLocation">null</property>

<!--Strongly disrecommended. Setting this to true may lead to subtle and bizarre bugs.
錛堟枃妗e師鏂囷級浣滆呭己鐑堝緩璁笉浣跨敤鐨勪竴涓睘鎬?->
<property name="forceIgnoreUnresolvedTransactions">false</property>

<!--姣?0縐掓鏌ユ墍鏈夎繛鎺ユ睜涓殑絀洪棽榪炴帴銆侱efault: 0 -->
<property name="idleConnectionTestPeriod">60</property>

<!--鍒濆鍖栨椂鑾峰彇涓変釜榪炴帴錛屽彇鍊煎簲鍦╩inPoolSize涓巑axPoolSize涔嬮棿銆侱efault: 3 -->
<property name="initialPoolSize">3</property>

<!--鏈澶х┖闂叉椂闂?60縐掑唴鏈嬌鐢ㄥ垯榪炴帴琚涪寮冦傝嫢涓?鍒欐案涓嶄涪寮冦侱efault: 0 -->
<property name="maxIdleTime">60</property>

<!--榪炴帴姹犱腑淇濈暀鐨勬渶澶ц繛鎺ユ暟銆侱efault: 15 -->
<property name="maxPoolSize">15</property>

<!--JDBC鐨勬爣鍑嗗弬鏁幫紝鐢ㄤ互鎺у埗鏁版嵁婧愬唴鍔犺澆鐨凱reparedStatements鏁伴噺銆備絾鐢變簬棰勭紦瀛樼殑statements
灞炰簬鍗曚釜connection鑰屼笉鏄暣涓繛鎺ユ睜銆傛墍浠ヨ緗繖涓弬鏁伴渶瑕佽冭檻鍒板鏂歸潰鐨勫洜绱犮?
濡傛灉maxStatements涓巑axStatementsPerConnection鍧囦負0錛屽垯緙撳瓨琚叧闂侱efault: 0-->
<property name="maxStatements">100</property>

<!--maxStatementsPerConnection瀹氫箟浜嗚繛鎺ユ睜鍐呭崟涓繛鎺ユ墍鎷ユ湁鐨勬渶澶х紦瀛榮tatements鏁般侱efault: 0 -->
<property name="maxStatementsPerConnection"></property>

<!--c3p0鏄紓姝ユ搷浣滅殑錛岀紦鎱㈢殑JDBC鎿嶄綔閫氳繃甯姪榪涚▼瀹屾垚銆傛墿灞曡繖浜涙搷浣滃彲浠ユ湁鏁堢殑鎻愬崌鎬ц兘
閫氳繃澶氱嚎紼嬪疄鐜板涓搷浣滃悓鏃惰鎵ц銆侱efault: 3-->
<property name="numHelperThreads">3</property>

<!--褰撶敤鎴瘋皟鐢╣etConnection()鏃朵嬌root鐢ㄦ埛鎴愪負鍘昏幏鍙栬繛鎺ョ殑鐢ㄦ埛銆備富瑕佺敤浜庤繛鎺ユ睜榪炴帴闈瀋3p0
鐨勬暟鎹簮鏃躲侱efault: null-->
<property name="overrideDefaultUser">root</property>

<!--涓巓verrideDefaultUser鍙傛暟瀵瑰簲浣跨敤鐨勪竴涓弬鏁般侱efault: null-->
<property name="overrideDefaultPassword">password</property>

<!--瀵嗙爜銆侱efault: null-->
<property name="password"></property>

<!--瀹氫箟鎵鏈夎繛鎺ユ祴璇曢兘鎵ц鐨勬祴璇曡鍙ャ傚湪浣跨敤榪炴帴嫻嬭瘯鐨勬儏鍐典笅榪欎釜涓鏄捐憲鎻愰珮嫻嬭瘯閫熷害銆傛敞鎰忥細
嫻嬭瘯鐨勮〃蹇呴』鍦ㄥ垵濮嬫暟鎹簮鐨勬椂鍊欏氨瀛樺湪銆侱efault: null-->
<property name="preferredTestQuery">select id from test where id=1</property>

<!--鐢ㄦ埛淇敼緋葷粺閰嶇疆鍙傛暟鎵ц鍓嶆渶澶氱瓑寰?00縐掋侱efault: 300 -->
<property name="propertyCycle">300</property>

<!--鍥犳ц兘娑堣楀ぇ璇峰彧鍦ㄩ渶瑕佺殑鏃跺欎嬌鐢ㄥ畠銆傚鏋滆涓簍rue閭d箞鍦ㄦ瘡涓猚onnection鎻愪氦鐨?
鏃跺欓兘灝嗘牎楠屽叾鏈夋晥鎬с傚緩璁嬌鐢╥dleConnectionTestPeriod鎴朼utomaticTestTable
絳夋柟娉曟潵鎻愬崌榪炴帴嫻嬭瘯鐨勬ц兘銆侱efault: false -->
<property name="testConnectionOnCheckout">false</property>

<!--濡傛灉璁句負true閭d箞鍦ㄥ彇寰楄繛鎺ョ殑鍚屾椂灝嗘牎楠岃繛鎺ョ殑鏈夋晥鎬с侱efault: false -->
<property name="testConnectionOnCheckin">true</property>

<!--鐢ㄦ埛鍚嶃侱efault: null-->
<property name="user">root</property>

<!--鏃╂湡鐨刢3p0鐗堟湰瀵笿DBC鎺ュ彛閲囩敤鍔ㄦ佸弽灝勪唬鐞嗐傚湪鏃╂湡鐗堟湰鐢ㄩ斿箍娉涚殑鎯呭喌涓嬭繖涓弬鏁?
鍏佽鐢ㄦ埛鎭㈠鍒板姩鎬佸弽灝勪唬鐞嗕互瑙e喅涓嶇ǔ瀹氱殑鏁呴殰銆傛渶鏂扮殑闈炲弽灝勪唬鐞嗘洿蹇茍涓斿凡緇忓紑濮?
騫挎硾鐨勮浣跨敤錛屾墍浠ヨ繖涓弬鏁版湭蹇呮湁鐢ㄣ傜幇鍦ㄥ師鍏堢殑鍔ㄦ佸弽灝勪笌鏂扮殑闈炲弽灝勪唬鐞嗗悓鏃跺彈鍒?
鏀寔錛屼絾浠婂悗鍙兘鐨勭増鏈彲鑳戒笉鏀寔鍔ㄦ佸弽灝勪唬鐞嗐侱efault: false-->
<property name="usesTraditionalReflectiveProxies">false</property>

<property name="automaticTestTable">con_test</property>
<property name="checkoutTimeout">30000</property>
<property name="idleConnectionTestPeriod">30</property>
<property name="initialPoolSize">10</property>
<property name="maxIdleTime">30</property>
<property name="maxPoolSize">25</property>
<property name="minPoolSize">10</property>
<property name="maxStatements">0</property>
<user-overrides user="swaldman">
</user-overrides>
</default-config>
<named-config name="dumbTestConfig">
<property name="maxStatements">200</property>
<user-overrides user="poop">
<property name="maxStatements">300</property>
</user-overrides>
</named-config>
</c3p0-config>


杞細http://www.wujianrong.com/archives/2007/08/c3p0.html瑙e喅MYSQL 8灝忔椂闂鏈榪戠殑涓涓」鐩湪Hibernate浣跨敤C3P0鐨勮繛鎺ユ睜錛屾暟鎹簱涓篗ysql銆傚紑鍙戞祴璇曟病鏈夐棶棰橈紝鍦ㄨ繍琛屼腑姣忎釜涓孌甸暱鐨勭┖闂叉椂闂村氨鍑虹幇寮傚父:

java 浠g爜org.hibernate.exception.JDBCConnectionException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:74)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
.......
Caused by: com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: No operations allowed after connection closed.Connection was implicitly closed due to underlying exception/error:


** BEGIN NESTED EXCEPTION **

com.mysql.jdbc.CommunicationsException
MESSAGE: Communications link failure due to underlying exception:

** BEGIN NESTED EXCEPTION **

java.net.SocketException
MESSAGE: Broken pipe

STACKTRACE:

java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
......
** END NESTED EXCEPTION **

鏌ョ湅浜哅ysql鐨勬枃妗o紝浠ュ強Connector/J鐨勬枃妗d互鍙婂湪綰胯鏄庡彂鐜幫紝鍑虹幇榪欑寮傚父鐨勫師鍥犳槸錛?br />
Mysql 鏈嶅姟鍣ㄩ粯璁ょ殑“wait_timeout”鏄?灝忔椂錛屼篃灝辨槸璇翠竴涓猚onnection絀洪棽瓚呰繃8涓皬鏃訛紝Mysql灝嗚嚜鍔ㄦ柇寮璇? connection銆傝繖灝辨槸闂鐨勬墍鍦紝鍦–3P0 pools涓殑connections濡傛灉絀洪棽瓚呰繃8灝忔椂錛孧ysql灝嗗叾鏂紑錛岃孋3P0騫朵笉鐭ラ亾璇onnection宸茬粡澶辨晥錛屽鏋滆繖鏃舵湁 Client璇鋒眰connection錛孋3P0灝嗚澶辨晥鐨凜onnection鎻愪緵緇機lient錛屽皢浼氶犳垚涓婇潰鐨勫紓甯搞?br />
瑙e喅鐨勬柟娉曟湁3縐嶏細

澧炲姞wait_timeout鐨勬椂闂淬?
鍑忓皯Connection pools涓璫onnection鐨刲ifetime銆?
嫻嬭瘯Connection pools涓璫onnection鐨勬湁鏁堟с?
褰撶劧鏈濂界殑鍔炴硶鏄悓鏃剁患鍚堜嬌鐢ㄤ笂榪?縐嶆柟娉曪紝涓嬮潰灝盌BCP鍜孋3P0鍒嗗埆鍋氫竴璇存槑錛屽亣璁緒ait_timeout涓洪粯璁ょ殑8灝忔椂

DBCP澧炲姞浠ヤ笅閰嶇疆淇℃伅:

//set to 'Select 1'
validationQuery = "Select 1"
//set to 'true'
testWhileIdle = "true"
//some positive integer
timeBetweenEvictionRunsMillis = 3600000
//set to something smaller than 'wait_timeout'
minEvictableIdleTimeMillis = 18000000
//if you don't mind a hit for every getConnection(), set to "true"
testOnBorrow = "true"

C3P0澧炲姞浠ヤ笅閰嶇疆淇℃伅:

//鑾峰彇connnection鏃舵祴璇曟槸鍚︽湁鏁?
testConnectionOnCheckin = true
//鑷姩嫻嬭瘯鐨則able鍚嶇О

automaticTestTable=C3P0TestTable

//set to something much less than wait_timeout, prevents connections from going stale
idleConnectionTestPeriod = 18000
//set to something slightly less than wait_timeout, preventing 'stale' connections from being handed out
maxIdleTime = 25000
//if you can take the performance 'hit', set to "true"
testConnectionOnCheckout = true

鏇村鐨勯厤緗俊鎭ぇ瀹跺彲浠ユ煡鐪婥3P0鏂囨。錛孋onnector/J鏂囨。錛屼互鍙奃BCP鐨勬枃妗c?br />
杞? http://www.iteye.com/article/38506

鎴戣嚜宸辯殑閰嶇疆:

jdbc.driverClass=com.mysql.jdbc.Driver
jdbc.jdbcUrl = jdbc:mysql://localhost:3306/test
jdbc.user = root
jdbc.password = 12345
jdbc.miniPoolSize = 1
jdbc.maxPoolSize = 20
jdbc.initialPoolSize = 1
jdbc.maxIdleTime = 25000
jdbc.acquireIncrement = 1

jdbc.acquireRetryAttempts = 30
jdbc.acquireRetryDelay = 1000
jdbc.testConnectionOnCheckin = true
jdbc.automaticTestTable = c3p0TestTable
jdbc.idleConnectionTestPeriod = 18000
jdbc.checkoutTimeout=3000

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
   <property name="driverClass" value="${jdbc.driverClass}" />
   <property name="jdbcUrl" value="${jdbc.jdbcUrl}" />
   <property name="user" value="${jdbc.user}" />
   <property name="password" value="${jdbc.password}" />
   <property name="minPoolSize" value="${jdbc.miniPoolSize}" />
   <property name="maxPoolSize" value="${jdbc.maxPoolSize}"/>  
   <property name="initialPoolSize" value="${jdbc.initialPoolSize}"/>
   <property name="maxIdleTime" value="${jdbc.maxIdleTime}"/>
   <property name="acquireIncrement" value="${jdbc.acquireIncrement}"/>
  
   <property name="acquireRetryAttempts" value="${jdbc.acquireRetryAttempts}"/>
   <property name="acquireRetryDelay" value="${jdbc.acquireRetryDelay}"/>
   <property name="testConnectionOnCheckin" value="${jdbc.testConnectionOnCheckin}"/>
   <property name="automaticTestTable" value="${jdbc.automaticTestTable}"/>
   <property name="idleConnectionTestPeriod" value="${jdbc.idleConnectionTestPeriod}"/>
   <property name="checkoutTimeout" value="${jdbc.checkoutTimeout}"/>

</bean>



瑗跨摐 2011-05-27 15:58 鍙戣〃璇勮
]]>
c3p0璇︾粏閰嶇疆http://m.tkk7.com/ashutc/archive/2011/03/16/346365.html瑗跨摐瑗跨摐Wed, 16 Mar 2011 02:31:00 GMThttp://m.tkk7.com/ashutc/archive/2011/03/16/346365.htmlhttp://m.tkk7.com/ashutc/comments/346365.htmlhttp://m.tkk7.com/ashutc/archive/2011/03/16/346365.html#Feedback0http://m.tkk7.com/ashutc/comments/commentRss/346365.htmlhttp://m.tkk7.com/ashutc/services/trackbacks/346365.html
<c3p0-config>
<default-config>
<!--褰撹繛鎺ユ睜涓殑榪炴帴鑰楀敖鐨勬椂鍊檆3p0涓嬈″悓鏃惰幏鍙栫殑榪炴帴鏁般侱efault: 3 -->
<property name="acquireIncrement">3</property>

<!--瀹氫箟鍦ㄤ粠鏁版嵁搴撹幏鍙栨柊榪炴帴澶辮觸鍚庨噸澶嶅皾璇曠殑嬈℃暟銆侱efault: 30 -->
<property name="acquireRetryAttempts">30</property>

<!--涓ゆ榪炴帴涓棿闅旀椂闂達紝鍗曚綅姣銆侱efault: 1000 -->
<property name="acquireRetryDelay">1000</property>

<!--榪炴帴鍏抽棴鏃墮粯璁ゅ皢鎵鏈夋湭鎻愪氦鐨勬搷浣滃洖婊氥侱efault: false -->
<property name="autoCommitOnClose">false</property>

<!--c3p0灝嗗緩涓寮犲悕涓篢est鐨勭┖琛紝騫朵嬌鐢ㄥ叾鑷甫鐨勬煡璇㈣鍙ヨ繘琛屾祴璇曘傚鏋滃畾涔変簡榪欎釜鍙傛暟閭d箞
灞炴referredTestQuery灝嗚蹇界暐銆備綘涓嶈兘鍦ㄨ繖寮燭est琛ㄤ笂榪涜浠諱綍鎿嶄綔錛屽畠灝嗗彧渚沜3p0嫻嬭瘯
浣跨敤銆侱efault: null-->
<property name="automaticTestTable">Test</property>

<!--鑾峰彇榪炴帴澶辮觸灝嗕細寮曡搗鎵鏈夌瓑寰呰繛鎺ユ睜鏉ヨ幏鍙栬繛鎺ョ殑綰跨▼鎶涘嚭寮傚父銆備絾鏄暟鎹簮浠嶆湁鏁?br /> 淇濈暀錛屽茍鍦ㄤ笅嬈¤皟鐢╣etConnection()鐨勬椂鍊欑戶緇皾璇曡幏鍙栬繛鎺ャ傚鏋滆涓簍rue錛岄偅涔堝湪灝濊瘯
鑾峰彇榪炴帴澶辮觸鍚庤鏁版嵁婧愬皢鐢蟲槑宸叉柇寮騫舵案涔呭叧闂侱efault: false-->
<property name="breakAfterAcquireFailure">false</property>

<!--褰撹繛鎺ユ睜鐢ㄥ畬鏃跺鎴風璋冪敤getConnection()鍚庣瓑寰呰幏鍙栨柊榪炴帴鐨勬椂闂達紝瓚呮椂鍚庡皢鎶涘嚭
SQLException,濡傝涓?鍒欐棤闄愭湡絳夊緟銆傚崟浣嶆縐掋侱efault: 0 -->
<property name="checkoutTimeout">100</property>

<!--閫氳繃瀹炵幇ConnectionTester鎴朡ueryConnectionTester鐨勭被鏉?/span> 嫻嬭瘯榪炴帴銆傜被鍚嶉渶鍒跺畾鍏ㄨ礬寰勩?br /> Default: com.mchange.v2.c3p0.impl.DefaultConnectionTester-->
<property name="connectionTesterClassName"></property>

<!--鎸囧畾c3p0 libraries鐨勮礬寰勶紝濡傛灉錛堥氬父閮芥槸榪欐牱錛夊湪鏈湴鍗沖彲鑾峰緱閭d箞鏃犻渶璁劇疆錛岄粯璁ull鍗沖彲
Default: null-->
<property name="factoryClassLocation">null</property>

<!--Strongly disrecommended. Setting this to true may lead to subtle and bizarre bugs.
錛堟枃妗e師鏂囷級浣滆呭己鐑堝緩璁笉浣跨敤鐨勪竴涓睘鎬?->
<property name="forceIgnoreUnresolvedTransactions">false</property>

<!--姣?0縐掓鏌ユ墍鏈夎繛鎺ユ睜涓殑絀洪棽榪炴帴銆侱efault: 0 -->
<property name="idleConnectionTestPeriod">60</property>

<!--鍒濆鍖栨椂鑾峰彇涓変釜榪炴帴錛屽彇鍊煎簲鍦╩inPoolSize涓巑axPoolSize涔嬮棿銆侱efault: 3 -->
<property name="initialPoolSize">3</property>

<!--鏈澶х┖闂叉椂闂?60縐掑唴鏈嬌鐢ㄥ垯榪炴帴琚涪寮冦傝嫢涓?鍒欐案涓嶄涪寮冦侱efault: 0 -->
<property name="maxIdleTime">60</property>

<!--榪炴帴姹犱腑淇濈暀鐨勬渶澶ц繛鎺ユ暟銆侱efault: 15 -->
<property name="maxPoolSize">15</property>

<!--JDBC鐨勬爣鍑嗗弬鏁幫紝鐢ㄤ互鎺у埗鏁版嵁婧愬唴鍔犺澆鐨凱reparedStatements鏁伴噺銆備絾鐢變簬棰勭紦瀛樼殑statements
灞炰簬鍗曚釜connection鑰屼笉鏄暣涓繛鎺ユ睜銆傛墍浠ヨ緗繖涓弬鏁伴渶瑕佽冭檻鍒板鏂歸潰鐨勫洜绱犮?br /> 濡傛灉maxStatements涓巑axStatementsPerConnection鍧囦負0錛屽垯緙撳瓨琚叧闂侱efault: 0-->
<property name="maxStatements">100</property>

<!--maxStatementsPerConnection瀹氫箟浜嗚繛鎺ユ睜鍐呭崟涓繛鎺ユ墍鎷ユ湁鐨勬渶澶х紦瀛榮tatements鏁般侱efault: 0 -->
<property name="maxStatementsPerConnection"></property>

<!--c3p0鏄紓姝ユ搷浣滅殑錛岀紦鎱㈢殑JDBC鎿嶄綔閫氳繃甯姪榪涚▼瀹屾垚銆傛墿灞曡繖浜涙搷浣滃彲浠ユ湁鏁堢殑鎻愬崌鎬ц兘
閫氳繃澶氱嚎紼嬪疄鐜板涓搷浣滃悓鏃惰鎵ц銆侱efault: 3-->

<property name="numHelperThreads">3</property>

<!--褰撶敤鎴瘋皟鐢╣etConnection()鏃朵嬌root鐢ㄦ埛鎴愪負鍘昏幏鍙栬繛鎺ョ殑鐢ㄦ埛銆備富瑕佺敤浜庤繛鎺ユ睜榪炴帴闈瀋3p0
鐨勬暟鎹簮鏃躲侱efault: null-->
<property name="overrideDefaultUser">root</property>

<!--涓巓verrideDefaultUser鍙傛暟瀵瑰簲浣跨敤鐨勪竴涓弬鏁般侱efault: null-->
<property name="overrideDefaultPassword">password</property>

<!--瀵嗙爜銆侱efault: null-->
<property name="password"></property>

<!--瀹氫箟鎵鏈夎繛鎺ユ祴璇曢兘鎵ц鐨勬祴璇曡鍙ャ傚湪浣跨敤榪炴帴嫻嬭瘯鐨勬儏鍐典笅榪欎釜涓鏄捐憲鎻愰珮嫻嬭瘯閫熷害銆傛敞鎰忥細
嫻嬭瘯鐨勮〃蹇呴』鍦ㄥ垵濮嬫暟鎹簮鐨勬椂鍊欏氨瀛樺湪銆侱efault: null-->

<property name="preferredTestQuery">select id from test where id=1</property>

<!--鐢ㄦ埛淇敼緋葷粺閰嶇疆鍙傛暟鎵ц鍓嶆渶澶氱瓑寰?00縐掋侱efault: 300 -->
<property name="propertyCycle">300</property>

<!--鍥犳ц兘娑堣楀ぇ璇峰彧鍦ㄩ渶瑕佺殑鏃跺欎嬌鐢ㄥ畠銆傚鏋滆涓簍rue閭d箞鍦ㄦ瘡涓猚onnection鎻愪氦鐨?br /> 鏃跺欓兘灝嗘牎楠屽叾鏈夋晥鎬с傚緩璁嬌鐢╥dleConnectionTestPeriod鎴朼utomaticTestTable
絳夋柟娉曟潵鎻愬崌榪炴帴嫻嬭瘯鐨勬ц兘銆侱efault: false -->
<property name="testConnectionOnCheckout">false</property>

<!--濡傛灉璁句負true閭d箞鍦ㄥ彇寰楄繛鎺ョ殑鍚屾椂灝嗘牎楠岃繛鎺ョ殑鏈夋晥鎬с侱efault: false -->
<property name="testConnectionOnCheckin">true</property>

<!--鐢ㄦ埛鍚嶃侱efault: null-->
<property name="user">root</property>

<!--鏃╂湡鐨刢3p0鐗堟湰瀵笿DBC鎺ュ彛閲囩敤鍔ㄦ佸弽灝勪唬鐞嗐傚湪鏃╂湡鐗堟湰鐢ㄩ斿箍娉涚殑鎯呭喌涓嬭繖涓弬鏁?br /> 鍏佽鐢ㄦ埛鎭㈠鍒板姩鎬佸弽灝勪唬鐞嗕互瑙e喅涓嶇ǔ瀹氱殑鏁呴殰銆傛渶鏂扮殑闈炲弽灝勪唬鐞嗘洿蹇茍涓斿凡緇忓紑濮?br /> 騫挎硾鐨勮浣跨敤錛屾墍浠ヨ繖涓弬鏁版湭蹇呮湁鐢ㄣ傜幇鍦ㄥ師鍏堢殑鍔ㄦ佸弽灝勪笌鏂扮殑闈炲弽灝勪唬鐞嗗悓鏃跺彈鍒?br /> 鏀寔錛屼絾浠婂悗鍙兘鐨勭増鏈彲鑳戒笉鏀寔鍔ㄦ佸弽灝勪唬鐞嗐侱efault: false-->
<property name="usesTraditionalReflectiveProxies">false</property>

<property name="automaticTestTable">con_test</property>
<property name="checkoutTimeout">30000</property>
<property name="idleConnectionTestPeriod">30</property>
<property name="initialPoolSize">10</property>
<property name="maxIdleTime">30</property>
<property name="maxPoolSize">25</property>
<property name="minPoolSize">10</property>
<property name="maxStatements">0</property>
<user-overrides user="swaldman">
</user-overrides>
</default-config>
<named-config name="dumbTestConfig">
<property name="maxStatements">200</property>
<user-overrides user="poop">
<property name="maxStatements">300</property>
</user-overrides>
</named-config>
</c3p0-config>


杞細http://www.wujianrong.com/archives/2007/08/c3p0.html
瑙e喅MYSQL 8灝忔椂闂

鏈榪戠殑涓涓」鐩湪Hibernate浣跨敤C3P0鐨勮繛鎺ユ睜錛屾暟鎹簱涓篗ysql銆傚紑鍙戞祴璇曟病鏈夐棶棰橈紝鍦ㄨ繍琛屼腑姣忎釜涓孌甸暱鐨勭┖闂叉椂闂村氨鍑虹幇寮傚父:

java 浠g爜
  1. org.hibernate.exception.JDBCConnectionException: could not execute query
  2. at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java: 74 )
  3. at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java: 43 )
  4. .......
  5. Caused by: com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: No operations allowed after connection closed.Connection was implicitly closed due to underlying exception/error:
  6. ** BEGIN NESTED EXCEPTION **
  7. com.mysql.jdbc.CommunicationsException
  8. MESSAGE: Communications link failure due to underlying exception:
  9. ** BEGIN NESTED EXCEPTION **
  10. java.net.SocketException
  11. MESSAGE: Broken pipe
  12. STACKTRACE:
  13. java.net.SocketException: Broken pipe
  14. at java.net.SocketOutputStream.socketWrite0(Native Method)
  15. ......
  16. ** END NESTED EXCEPTION **

鏌ョ湅浜哅ysql鐨勬枃妗o紝浠ュ強Connector/J鐨勬枃妗d互鍙婂湪綰胯鏄庡彂鐜幫紝鍑虹幇榪欑寮傚父鐨勫師鍥犳槸錛?/p>

Mysql鏈嶅姟鍣ㄩ粯璁ょ殑“wait_timeout”鏄?灝忔椂錛屼篃灝辨槸璇翠竴涓猚onnection絀洪棽瓚呰繃8涓皬鏃訛紝Mysql灝嗚嚜鍔ㄦ柇寮璇? connection銆傝繖灝辨槸闂鐨勬墍鍦紝鍦–3P0 pools涓殑connections濡傛灉絀洪棽瓚呰繃8灝忔椂錛孧ysql灝嗗叾鏂紑錛岃孋3P0騫朵笉鐭ラ亾璇onnection宸茬粡澶辨晥錛屽鏋滆繖鏃舵湁 Client璇鋒眰connection錛孋3P0灝嗚澶辨晥鐨凜onnection鎻愪緵緇機lient錛屽皢浼氶犳垚涓婇潰鐨勫紓甯搞?/p>

瑙e喅鐨勬柟娉曟湁3縐嶏細

  1. 澧炲姞wait_timeout鐨勬椂闂淬?
  2. 鍑忓皯Connection pools涓璫onnection鐨刲ifetime銆?
  3. 嫻嬭瘯Connection pools涓璫onnection鐨勬湁鏁堟с?

褰撶劧鏈濂界殑鍔炴硶鏄悓鏃剁患鍚堜嬌鐢ㄤ笂榪?縐嶆柟娉曪紝涓嬮潰灝盌BCP鍜孋3P0鍒嗗埆鍋氫竴璇存槑錛屽亣璁緒ait_timeout涓洪粯璁ょ殑8灝忔椂

DBCP澧炲姞浠ヤ笅閰嶇疆淇℃伅:

  1. //set to 'SELECT 1'
  2. validationQuery = "SELECT 1"
  3. //set to 'true'
  4. testWhileIdle = "true"
  5. //some positive integer
  6. timeBetweenEvictionRunsMillis = 3600000
  7. //set to something smaller than 'wait_timeout'
  8. minEvictableIdleTimeMillis = 18000000
  9. //if you don't mind a hit for every getConnection(), set to "true"
  10. testOnBorrow = "true"

C3P0澧炲姞浠ヤ笅閰嶇疆淇℃伅:

  1. //鑾峰彇connnection鏃舵祴璇曟槸鍚︽湁鏁?/span>
  2. testConnectionOnCheckin = true
  3. //鑷姩嫻嬭瘯鐨則able鍚嶇О
  4. automaticTestTable=C3P0TestTable
  5. //set to something much less than wait_timeout, prevents connections from going stale
  6. idleConnectionTestPeriod = 18000
  7. //set to something slightly less than wait_timeout, preventing 'stale' connections from being handed out
  8. maxIdleTime = 25000
  9. //if you can take the performance 'hit', set to "true"
  10. testConnectionOnCheckout = true

鏇村鐨勯厤緗俊鎭ぇ瀹跺彲浠ユ煡鐪婥3P0鏂囨。錛孋onnector/J鏂囨。錛屼互鍙奃BCP鐨勬枃妗c?/p>

杞? http://www.javaeye.com/article/38506

鎴戣嚜宸辯殑閰嶇疆:

jdbc.driverClass=com.mysql.jdbc.Driver
jdbc.jdbcUrl = jdbc:mysql://localhost:3306/test
jdbc.user = root
jdbc.password = 12345
jdbc.miniPoolSize = 1
jdbc.maxPoolSize = 20
jdbc.initialPoolSize = 1
jdbc.maxIdleTime = 25000
jdbc.acquireIncrement = 1

jdbc.acquireRetryAttempts = 30
jdbc.acquireRetryDelay = 1000
jdbc.testConnectionOnCheckin = true
jdbc.automaticTestTable = c3p0TestTable
jdbc.idleConnectionTestPeriod = 18000
jdbc.checkoutTimeout=3000

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
   <property name="driverClass" value="${jdbc.driverClass}" />
   <property name="jdbcUrl" value="${jdbc.jdbcUrl}" />
   <property name="user" value="${jdbc.user}" />
   <property name="password" value="${jdbc.password}" />
   <property name="minPoolSize" value="${jdbc.miniPoolSize}" />
   <property name="maxPoolSize" value="${jdbc.maxPoolSize}"/>  
   <property name="initialPoolSize" value="${jdbc.initialPoolSize}"/>
   <property name="maxIdleTime" value="${jdbc.maxIdleTime}"/>
   <property name="acquireIncrement" value="${jdbc.acquireIncrement}"/>
  
   <property name="acquireRetryAttempts" value="${jdbc.acquireRetryAttempts}"/>
   <property name="acquireRetryDelay" value="${jdbc.acquireRetryDelay}"/>
   <property name="testConnectionOnCheckin" value="${jdbc.testConnectionOnCheckin}"/>
   <property name="automaticTestTable" value="${jdbc.automaticTestTable}"/>
   <property name="idleConnectionTestPeriod" value="${jdbc.idleConnectionTestPeriod}"/>
   <property name="checkoutTimeout" value="${jdbc.checkoutTimeout}"/>

</bean>

+++++++++++

鎶ラ敊璇細
APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks!

涓鑸緗甿axStatements=0瑙e喅璇ラ棶棰?
浣嗘槸錛?
鎶妋ax_statements璁劇疆涓?銆?
c3p0鍦ㄥ悓鏃跺叧闂璼tatement鍜宑onnection鐨勬椂鍊欙紝鎴栬呭叧闂粬浠箣闂寸殑鏃墮棿寰堢煭鐨勬椂鍊欙紝鏈夋椂鍊檆onnection騫舵病鏈夎鍏抽棴錛屽洜涓烘湁浜沺reparedstatement榪樺湪琚玞ached浣忋傝繖鏄痗3p0鐨勪綔鑰呰嚜宸辮鐨勩?
http://forum.hibernate.org/viewtopic.php?t=947246&highlight=apparent+deadlock+c3p0

C3P0澧炲姞浠ヤ笅閰嶇疆淇℃伅:


//set to 'SELECT 1'      
preferredTestQuery = 'SELECT 1'    
//set to something much less than wait_timeout, prevents connections from going stale   
idleConnectionTestPeriod = 18000     
//set to something slightly less than wait_timeout, preventing 'stale' connections from being handed out   
maxIdleTime = 25000    
//if you can take the performance 'hit', set to "true"   
testConnectionOnCheckout = true    



A c3p0 pool with the settings you have should recover from a database reset, but that doesn't mean you will never see an Exception. Stale Connections from the old database session will still be broken, and if those Connections have already been checked out, or if they are in the pool and not tested on checkout, the application will see the broken Connection, in the form of an Exception.

You can use c3p0 to minimize the likelihood that your application will see a stale Connection on database shutdown/restart. The most reliable means of preventing this is to set hibernate.c3p0.validate to true (in a hibernate application -- all other c3p0 apps should use the c3p0-native property c3p0.testConnectionOnCheckout). If you set this property to true, c3p0 will test Connections prior to checkout, and your app will never see a stale Connection on database restart unless the Connection had already been checked out when the database went down.

Another less reliable, but potentially less expensive, strategy is to set c3p0.testConnectionsOnCheckin and hibernate.c3p0.idle_test_period (c3p0-native c3p0.idleConnectionTestPeriod) to a low value, in which case all connection tests are asynchronous and you are guanteed that no Connection will be checked out that hasn't been tested in the last idle_test_period seconds. Thus, your app will only see broken Connections from the pool if Connections are checked out during a short window of time.

In either case, I recommend setting "c3p0.preferredTestQuery " or "c3p0.automaticTestTable" in your c3p0 properties file, as c3p0's default Connection test is often slow.

See "Configuring Connection Testing" in c3p0's docs for more information.



鍦? 浣跨敤c3p0浣滀負榪炴帴姹犳椂錛屽叾涓殑涓浜涢厤緗弬鏁伴渶瑕佷慨鏀廣備富瑕佹槸maxIdleTime鍜宨dleConnectionTestPeriod銆? MySQL榛樿鏄?灝忔椂錛?8800縐掞級鍚庤嚜鍔ㄥ叧闂凡鎵撳紑鐨勮繛鎺ワ紝鎵浠3p0瑕佸湪8灝忔椂鍐呭叧闂笉浣跨敤鐨勮繛鎺ワ紝涓婇潰鐨?鍙傛暟瑕佸皬浜?8800縐掋傞檮涓婂湪 hibernate涓厤緗甤3p0鐨勫叧閿瓧銆?

c3p0-native property name hibernate configuration key
c3p0.acquireIncrement hibernate.c3p0.acquire_increment
c3p0.idleConnectionTestPeriod hibernate.c3p0.idle_test_period
c3p0.initialPoolSize not available -- uses minimum size
c3p0.maxIdleTime hibernate.c3p0.timeout
c3p0.maxPoolSize hibernate.c3p0.max_size
c3p0.maxStatements hibernate.c3p0.max_statements
c3p0.minPoolSize hibernate.c3p0.min_size

杞澆鑷細http://handawei.javaeye.com/blog/651046




瑗跨摐 2011-03-16 10:31 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 亚洲网站在线观看| 蜜臀91精品国产免费观看| 好紧我太爽了视频免费国产| 成年网站免费入口在线观看| 香蕉视频亚洲一级| 久久水蜜桃亚洲AV无码精品| 亚洲国产精品网站在线播放| 亚洲欧美自偷自拍另类视| 亚洲精品动漫免费二区| 亚洲AV日韩AV永久无码色欲 | 成年人免费视频观看| 成年人网站免费视频| 免费可以在线看A∨网站| 久久精品a一国产成人免费网站| 久久久久久国产a免费观看黄色大片 | 亚洲av无码专区首页| 大桥未久亚洲无av码在线| 免费国产高清毛不卡片基地| 欧洲美女大片免费播放器视频| CAOPORM国产精品视频免费| 免费无码又爽又刺激高潮软件| 老汉精品免费AV在线播放| 在线观看H网址免费入口| 在线观看免费成人| 免费v片在线观看| 亚洲精品一品区二品区三品区| 久久精品国产96精品亚洲| 亚洲一区动漫卡通在线播放| 亚洲精品无码中文久久字幕| 麻豆一区二区三区蜜桃免费| 免费无码又爽又刺激网站直播| 1000部拍拍拍18勿入免费视频下载 | 亚洲免费在线视频播放| 四虎影院在线免费播放| 亚洲乱码国产一区网址| 亚洲高清视频在线观看| 在线观看亚洲AV日韩AV| a级毛片免费观看在线| 1000部啪啪未满十八勿入免费| 四虎影视大全免费入口| 久久久久久久亚洲精品|