¿El subproceso del grupo de conexiones c3p0 es seguro o no?

hai this chandrashekhar,

when I post the multiple requests(100) at a time it creates c3p0 Instances.

Ex::

 [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] 

....etc 100 times.

what is the meaning behind this, is 100 connection pool Instances created..? is c3p0 connection pool is not thread safe..? if so how we are geoing to handle..?

pls any one help me.

thanks in advance, ChandraShekhar

preguntado el 24 de agosto de 12 a las 10:08

1 Respuestas

Firstly, a connection can only run on interaction with the database at a time. If you share a connection across multiple threads, the behaviour would be random. Ideally, you would just get a connection from the pool when you want to interact with DB like run some INSERT/UPDATE/DELETE statements and get the update counts or run SELECT statements and read the result sets and then you close all the resources (viz. ResultSets, Statements and Connection).

If the connection comes from a connection pooler, then the close() call on such a connection is handled by the pooler to return the connection back to pool.

The statements you printed are INFOs from the pooler about the connection pool created.

Respondido 20 Feb 14, 16:02

could you please expain in detail. - Chandra Shekhar Goka

Which part of the above response do you want to be detailed? - víkdor

BTW, are you facing any issues with your setup? - víkdor

could you please explain in detail. ok obviously every time we got a connection from pool. But as I know that initially when I post the multiple requests the pool could be created only once. Remaining connections will be fetched from that pool itself. But in this case multiple pools are created. why it is possible. - Chandra Shekhar Goka

yes I faced a problem. after 100 times printed I got an exception like ::com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Data source rejected establishment of connection, message from server: "Too many connections" at sun.reflect.GeneratedConstructorAccessor927.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:513) at com.mysql.jdbc.Util.handleNewInstance(Util.java:409) - Chandra Shekhar Goka

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.