ComboPooledDataSource 詳細配置說明,basicdatasource配置

來源:互聯網
上載者:User

ComboPooledDataSource 詳細配置說明,basicdatasource配置
ComboPooledDataSource 詳細配置說明
<default-config>
<!--當串連池中的串連耗盡的時候c3p0一次同時擷取的串連數。Default: 3 -->
<property name="acquireIncrement">3</property><!--定義在從資料庫擷取新串連失敗後重複嘗試的次數。Default: 30 -->
 <property name="acquireRetryAttempts">30</property><!--兩次串連中間隔時間,單位毫秒。Default: 1000 -->
 <property name="acquireRetryDelay">1000</property><!--串連關閉時預設將所有未提交的操作復原。Default: false -->
<property name="autoCommitOnClose">false</property><!--c3p0將建一張名為Test的空表,並使用其內建的查詢語句進行測試。如果定義了這個參數那麼屬性preferredTestQuery將被忽略。你不能在這張Test表上進行任何操作,它將只供c3p0測試使用。Default: null-->
<property name="automaticTestTable">Test</property> <!--擷取串連失敗將會引起所有等待串連池來擷取串連的線程拋出異常。但是資料來源仍有效保留,並在下次調用getConnection()的時候繼續嘗試擷取串連。如果設為true,那麼在嘗試擷取串連失敗後該資料來源將申明已斷開並永久關閉。Default: false-->
<property name="breakAfterAcquireFailure">false</property><!--當串連池用完時用戶端調用getConnection()後等待擷取新串連的時間,逾時後將拋出SQLException,如設為0則無限期等待。單位毫秒。Default: 0 -->
<property name="checkoutTimeout">100</property><!--通過實現ConnectionTester或QueryConnectionTester的類來測試連接。類名需制定全路徑。Default: com.mchange.v2.c3p0.impl.DefaultConnectionTester-->
<property name="connectionTesterClassName"></property><!--指定c3p0 libraries的路徑,如果(通常都是這樣)在本地即可獲得那麼無需設定,預設null即可Default: null-->
<property name="factoryClassLocation">null</property><!--Strongly disrecommended. Setting this to true may lead to subtle and bizarre bugs.(文檔原文)作者強烈建議不使用的一個屬性-->
<property name="forceIgnoreUnresolvedTransactions">false</property><!--每60秒檢查所有串連池中的空閑串連。Default: 0 -->
<property name="idleConnectionTestPeriod">60</property><!--初始化時擷取三個串連,取值應在minPoolSize與maxPoolSize之間。Default: 3 -->
<property name="initialPoolSize">3</property><!--最大空閑時間,60秒內未使用則串連被丟棄。若為0則永不丟棄。Default: 0 -->
<property name="maxIdleTime">60</property><!--串連池中保留的最大串連數。Default: 15 -->
<property name="maxPoolSize">15</property><!--JDBC的標準參數,用以控制資料來源內載入的PreparedStatements數量。但由於預緩衝的statements屬於單個connection而不是整個串連池。所以設定這個參數需要考慮到多方面的因素。如果maxStatements與maxStatementsPerConnection均為0,則緩衝被關閉。Default: 0-->
<property name="maxStatements">100</property><!--maxStatementsPerConnection定義了串連池內單個串連所擁有的最大緩衝statements數。Default: 0 -->
<property name="maxStatementsPerConnection"></property><!--c3p0是非同步作業的,緩慢的JDBC操作通過協助進程完成。擴充這些操作可以有效提升效能通過多線程實現多個操作同時被執行。Default: 3-->
<property name="numHelperThreads">3</property><!--當使用者調用getConnection()時使root使用者成為去擷取串連的使用者。主要用於串連池串連非c3p0的資料來源時。Default: null-->
<property name="overrideDefaultUser">root</property><!--與overrideDefaultUser參數對應使用的一個參數。Default: null-->
<property name="overrideDefaultPassword">password</property><!--密碼。Default: null-->
<property name="password"></property><!--定義所有串連測試都執行的測試語句。在使用串連測試的情況下這個一顯著提高測試速度。注意:測試的表必須在初始資料來源的時候就存在。Default: null-->
<property name="preferredTestQuery">select id from test where id=1</property><!--使用者修改系統配置參數執行前最多等待300秒。Default: 300 -->
<property name="propertyCycle">300</property><!--因效能消耗大請只在需要的時候使用它。如果設為true那麼在每個connection提交的時候都將校正其有效性。建議使用idleConnectionTestPeriod或automaticTestTable等方法來提升串連測試的效能。Default: false -->
<property name="testConnectionOnCheckout">false</property><!--如果設為true那麼在取得串連的同時將校正串連的有效性。Default: false -->
<property name="testConnectionOnCheckin">true</property><!--使用者名稱。Default: null-->
<property name="user">root</property>在Hibernate(spring管理)中的配置:<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"><property name="driverClass"><value>oracle.jdbc.driver.OracleDriver</value></property><property name="jdbcUrl"><value>jdbc:oracle:thin:@localhost:1521:Test</value></property><property name="user"><value>Kay</value></property><property name="password"><value>root</value></property><!--串連池中保留的最小串連數。-->
<property name="minPoolSize" value="10" /><!--串連池中保留的最大串連數。Default: 15 -->
<property name="maxPoolSize" value="100" /><!--最大空閑時間,1800秒內未使用則串連被丟棄。若為0則永不丟棄。Default: 0 -->
<property name="maxIdleTime" value="1800" /><!--當串連池中的串連耗盡的時候c3p0一次同時擷取的串連數。Default: 3 -->
<property name="acquireIncrement" value="3" /><property name="maxStatements" value="1000" /><property name="initialPoolSize" value="10" /><!--每60秒檢查所有串連池中的空閑串連。Default: 0 -->
<property name="idleConnectionTestPeriod" value="60" /><!--定義在從資料庫擷取新串連失敗後重複嘗試的次數。Default: 30 -->
<property name="acquireRetryAttempts" value="30" /><property name="breakAfterAcquireFailure" value="true" /><property name="testConnectionOnCheckout" value="false" /></bean>############################## C3P0 Connection Pool###############################hibernate.c3p0.max_size 2#hibernate.c3p0.min_size 2#hibernate.c3p0.timeout 5000#hibernate.c3p0.max_statements 100#hibernate.c3p0.idle_test_period 3000#hibernate.c3p0.acquire_increment 2#hibernate.c3p0.validate false在hibernate.cfg.xml檔案裡面加入如下的配置:<!-- 最大串連數 -->
<property name="hibernate.c3p0.max_size">20</property><!-- 最小串連數 -->
<property name="hibernate.c3p0.min_size">5</property><!-- 獲得串連的逾時時間,如果超過這個時間,會拋出異常,單位毫秒 -->
<property name="hibernate.c3p0.timeout">120</property><!-- 最大的PreparedStatement的數量 -->
<property name="hibernate.c3p0.max_statements">100</property><!-- 每隔120秒檢查串連池裡的空閑串連 ,單位是秒-->
<property name="hibernate.c3p0.idle_test_period">120</property><!-- 當串連池裡面的串連用完的時候,C3P0一下擷取的新的串連數 -->
<property name="hibernate.c3p0.acquire_increment">2</property><!-- 每次都驗證串連是否可用 -->
<property name="hibernate.c3p0.validate">true</property>

相關文章

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.