Spring c3p0 接続プール構成 com.mchange.v2.c3p0.combopooleddatasource
2022-02-26 01:40:08
<default-config>
<! -- The number of connections c3p0 will acquire at once when the connection pool runs out of connections. default: 3 -->
<property name="acquireIncrement">3</property>
<! -- Defines the number of repeated attempts after a failed attempt to get a new connection from the database. default: 30 -->
<property name="acquireRetryAttempts">30</property>
<! -- Time between connections, in milliseconds. default: 1000 -->
<property name="acquireRetryDelay">1000</property>
<! -- Rollback all uncommitted operations by default when the connection is closed. default: false -->
<property name="autoCommitOnClose">false</property>
<! --c3p0 will create an empty table named Test and test it with its own query statement. If this parameter is defined then the
propertypreferredTestQuery will be ignored. You cannot perform any operations on this Test table, it will only be used by c3p0 for testing.
Default: null -->
<property name="automaticTestTable">Test</property>
<! -- Failing to get a connection will cause all threads waiting for the connection pool to get a connection to throw an exception. But the data source is still valid
is retained and the next call to getConnection() will continue to try to get the connection. If set to true, then the data source will be retained after a failed attempt to
Default: false -->
<property name="breakAfterAcquireFailure">false</property>
<! -- When the connection pool is exhausted, the client calls getConnection() and waits for the time to get a new connection, after the timeout will throw
SQLException, if set to 0, then wait indefinitely. Default: 0 -->
<property name="checkoutTimeout">100</property>
<! -- Test the connection by means of a class that implements ConnectionTester or QueryConnectionTester. The full path needs to be developed for the class name.
Default: com.mchange.v2.c3p0.impl.DefaultConnectionTester -->
<property name="connectionTesterClassName"></property>
<! -- Specify the path to the c3p0 libraries, if (as is often the case) they are available locally then there is no need to set them, the default is null
Default: null -->
<property name="factoryClassLocation">null</property>
<! --Setting this to true may lead to subtle and bizarre bugs.
(Original document) One property that the authors strongly recommend not using -->
<property name="forceIgnoreUnresolvedTransactions">false</property>
<! --check all idle connections in the connection pool every 60 seconds.Default: 0 -->
<property name="idleConnectionTestPeriod">60</property>
<! --Initialize to get three connections, the value should be between minPoolSize and maxPoolSize. default: 3 -->
<property name="initialPoolSize">3</property>
<! --Maximum idle time, if not used within 60 seconds, the connection is dropped. Default: 0 -->
<property name="maxIdleTime">60</property>
<! --max number of connections to keep in the connection pool. default: 15 -->
<property name="maxPoolSize">15</property>
<! -- A standard JDBC parameter to control the number of PreparedStatements loaded within the data source. However, since the pre-cached statements
belong to a single connection and not to the entire connection pool. So setting this parameter takes into account various factors.
If both maxStatements and maxStatementsPerConnection are 0, the cache is turned off. default: 0 -->
<property name="maxStatements">100</property>
<! --maxStatementsPerConnection defines the maximum number of cached statements a single connection can have within the connection pool.Default: 0 -->
<property name="maxStatementsPerConnection"></property>
<! --c3p0 is operated asynchronously and slow JDBC operations are done through helper processes. Extending these operations can effectively improve performance
Default: 3 -->
<property name="numHelperThreads">3</property>
<! -- Makes the root user the user who goes to get the connection when the user calls getConnection(). This is mainly used when connection pools connect to non-c3p0 data sources.
Default: null -->
<property name="overrideDefaultUser">root</property>
<! --one parameter used in correspondence with the overrideDefaultUser parameter. default: null -->
<property name="overrideDefaultPassword">password</property>
<! --password. default: null -->
<property name="password"></property>
<! -- Defines the test statements that are executed by all connection tests. This one significantly improves the speed of testing in the case of using connection tests. Caution.
The test of
The validity of the test will be verified when the test is run. It is recommended to use methods such as idleConnectionTestPeriod or automaticTestTable
Default: false -->
<property name="testConnectionOnCheckout">false</property>
<! --Default: false -->
<property name="testConnectionOnCheckin">true</property>
<! --username. default: null -->
<property name="user">root</property>
Configuration in Hibernate (spring admin).
<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>
<! -- The minimum number of connections to keep in the connection pool. -->
<property name="minPoolSize" value="10" />
<! -- The maximum number of connections to keep in the connection pool. default: 15 -->
<property name="maxPoolSize" value="100" />
<! --Maximum idle time, if not used within 1800 seconds then the connection is dropped. Default: 0 -->
<property name="maxIdleTime" value="1800" />
<! -- The number of connections c3p0 will fetch at once when the connection pool runs out of connections. default: 3 -->
<property name="acquireIncrement" value="3" />
<property name="maxStatements" value="1000" />
<property name="initialPoolSize" value="10" />
<! -- Check all idle connections in the connection pool every 60 seconds. default: 0 -->
<property name="idleConnectionTestPeriod" value="60" />
<! -- Defines the number of repeated attempts after a failed attempt to get a new connection from the database. 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
Add the following configuration to the hibernate.cfg.xml file.
<! --max-join-count -->
<property name="hibernate.c3p0.max_size">20</property>
<! -- Minimum number of connections -->
<property name="hibernate.c3p0.min_size">5</property>
<! -- Get the timeout of the connection, if it exceeds this time, an exception will be thrown in milliseconds -->
<property name="hibernate.c3p0.timeout">120</property>
<! -- the maximum number of PreparedStatements -- >
<property name="hibernate.c3p0.max_statements">100</property>
<! -- Check for free connections in the connection pool every 120 seconds, in seconds -- >
<property name="hibernate.c3p0.idle_test_period">120</property>
<! -- The number of new connections C3P0 gets at once when the connections inside the connection pool run out -- >
<property name="hibernate.c3p0.acquire_increment">2</property>
<! -- verify that the connection is available every time -->
<property name="hibernate.c3p0.validate">true</property>
関連
-
SLF4J: クラスパスが複数の SLF4J バインディングを含んでいる Error
-
Java の例外解決。コンストラクタの呼び出しはコンストラクタ内の最初のステートメントでなければならない
-
環境変数JAVA_HOME(値xxx)が有効なJVMのインストール先を指していません。
-
java にリソースリークがある: 'input' が閉じられない Solution
-
エラー コンストラクタ worker(int, String, float) は未定義です。
-
svn: 接続から読み取ることができません。リモートホストが既存の接続を強制的に閉じました。
-
JIRA REST API 呼び出し方法
-
org.apache.tools.zip を使用した Zip 圧縮・解凍
-
Linux (Centos) に Java jdk をインストールしてテストするとエラーが出る - bash: java: command not found
-
JAXBContextImpl を com.sun.xml.bind.v2.runtime.JAXBContextImpl にキャストできない com.sun.xml.internal.bind.api.JAXBRICoにキャストできない。
最新
-
nginxです。[emerg] 0.0.0.0:80 への bind() に失敗しました (98: アドレスは既に使用中です)
-
htmlページでギリシャ文字を使うには
-
ピュアhtml+cssでの要素読み込み効果
-
純粋なhtml + cssで五輪を実現するサンプルコード
-
ナビゲーションバー・ドロップダウンメニューのHTML+CSSサンプルコード
-
タイピング効果を実現するピュアhtml+css
-
htmlの選択ボックスのプレースホルダー作成に関する質問
-
html css3 伸縮しない 画像表示効果
-
トップナビゲーションバーメニュー作成用HTML+CSS
-
html+css 実装 サイバーパンク風ボタン
おすすめ
-
Javaでエラーが発生しました。非静的フィールドへの静的な参照を作成できません。
-
エラー: jdkのバージョンの問題により、クエリへの参照が曖昧になる
-
Springの構成でエラーなくIntelliJのアイデア、アセンブリオブジェクトは、自動配線できませんでした。
-
XXX型を囲むインスタンスはアクセスできない問題をJavaで解決
-
未処理の例外:java.text.ParseException
-
Javaで未処理の例外が発生する理由
-
中に内部エラーが発生しました。「pro-test 用のディスクリプタをロードしています。
-
Java の詳細です。Listはadd(null)できる?
-
メソッド起動時に InvocationException が発生しました。
-
IDEAが新しいプロジェクトを実行すると、Error running 'XXXApplication' と表示されます。XXXAppのコマンドラインを短くしてください。