这是chandrashekhar,
当我一次发布多个请求(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连接池是不是线程安全..?如果是这样我们如何处理......?
请任何人帮助我。
提前谢谢, 钱德拉希克哈答案 0 :(得分:1)
首先,连接只能在一次与数据库交互时运行。如果您跨多个线程共享连接,则行为将是随机的。理想情况下,当您想要与DB交互时,只需运行一些INSERT / UPDATE / DELETE语句并获取更新计数或运行SELECT语句并读取结果集然后关闭所有资源(即viz) 。结果集,陈述和连接)。
如果连接来自连接池,那么pooler会处理此类连接上的close()调用,以将连接返回池中。
您打印的语句是来自pooler的有关创建的连接池的INFO。