0

嗨,这个钱德拉谢卡,

当我一次发布多个请求(100)时,它会创建 c3p0 实例。

前任::

 [AbstractPoolBackedDataSource] Initializing c3p0 pool...
 com.mchange.v2.c3p0.PoolBackedDataSource@3b9421d5 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@8f5cd4d1 [ acquireIncrement -> 5, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> true, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, debugUnreturnedConnectionStackTraces -> true, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge2v08pob8zy1nl2rit|1474b36, idleConnectionTestPeriod -> 3600, initialPoolSize -> 10, maxAdministrativeTaskTime -> 600, maxConnectionAge -> 0, maxIdleTime -> 18000, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 50, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 10, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@3a7ecbf6 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 1hge2v08pob8zy1nl2rit|87f988, jdbcUrl -> jdbc:mysql://localhost:3306/tiscover, properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 600, usesTraditionalReflectiveProxies -> false; userOverrides: {} ], dataSourceName -> null, factoryClassLocation -> null, identityToken -> 1hge2v08pob8zy1nl2rit|6c2668, numHelperThreads -> 10 ]
13:24:16,003 INFO  [AbstractPoolBackedDataSource]
 Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@38d1c65b [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@efa9b134 [ acquireIncrement -> 5, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> true, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, debugUnreturnedConnectionStackTraces -> true, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge2v08pob8zy1nl2rit|d46725, idleConnectionTestPeriod -> 3600, initialPoolSize -> 10, maxAdministrativeTaskTime -> 600, maxConnectionAge -> 0, maxIdleTime -> 18000, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 50, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 10, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@f3230993 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 1hge2v08pob8zy1nl2rit|b31fb1, jdbcUrl -> jdbc:mysql://localhost:3306/tiscover, properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 600, usesTraditionalReflectiveProxies -> false; userOverrides: {} ], dataSourceName -> null, factoryClassLocation -> null, identityToken -> 1hge2v08pob8zy1nl2rit|9861d7, numHelperThreads -> 10 ]
13:24:16,004 INFO  [AbstractPoolBackedDataSource] 
Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@3b6dc297 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@433920d4 [ acquireIncrement -> 5, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> true, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, debugUnreturnedConnectionStackTraces -> true, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge2v08pob8zy1nl2rit|3561b9, idleConnectionTestPeriod -> 3600, initialPoolSize -> 10, maxAdministrativeTaskTime -> 600, maxConnectionAge -> 0, maxIdleTime -> 18000, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 50, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 10, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@4084843c [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 1hge2v08pob8zy1nl2rit|3f9de3, jdbcUrl -> jdbc:mysql://localhost:3306/tiscover, properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 600, usesTraditionalReflectiveProxies -> false; userOverrides: {} ], dataSourceName -> null, factoryClassLocation -> null, identityToken -> 1hge2v08pob8zy1nl2rit|6dfb07, numHelperThreads -> 10 ]
13:24:16,004 INFO  [AbstractPoolBackedDataSource] 
Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@3bcf7210 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@896b85d4 [ acquireIncrement -> 5, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> true, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, debugUnreturnedConnectionStackTraces -> true, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge2v08pob8zy1nl2rit|16e47cb, idleConnectionTestPeriod -> 3600, initialPoolSize -> 10, maxAdministrativeTaskTime -> 600, maxConnectionAge -> 0, maxIdleTime -> 18000, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 50, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 10, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@f06dd726 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 1hge2v08pob8zy1nl2rit|bd7db5, jdbcUrl -> jdbc:mysql://localhost:3306/tiscover, properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 600, usesTraditionalReflectiveProxies -> false; userOverrides: {} ], dataSourceName -> null, factoryClassLocation -> null, identityToken -> 1hge2v08pob8zy1nl2rit|1e616dc, numHelperThreads -> 10 ]
13:24:16,006 INFO  [AbstractPoolBackedDataSource] 

....等 100 次。

这背后的含义是什么,是否创建了 100 个连接池实例..?c3p0 连接池不是线程安全的吗?如果是这样,我们将如何处理..?

请任何人帮助我。

提前致谢, ChandraShekhar

4

1 回答 1

1

首先,连接一次只能在与数据库交互时运行。如果您跨多个线程共享连接,则行为将是随机的。理想情况下,当您想与数据库交互时,您只需从池中获得一个连接,例如运行一些 INSERT/UPDATE/DELETE 语句并获取更新计数或运行 SELECT 语句并读取结果集,然后关闭所有资源(即.ResultSets、语句和连接)。

如果连接来自连接池,则对此类连接的 close() 调用由池处理以将连接返回池。

您打印的语句是来自池程序的关于创建的连接池的信息。

于 2012-08-24T09:57:30.713 回答