Mysql连接池问题

时间:2022-09-19 23:14:30
17/03/29 09:07:23 WARN resourcepool.BasicResourcePool: com.mchange.v2.resourcepool.BasicResourcePool@67d8bcd1 -- an attempt to checkout a resource was interrupted, and the pool is still live: some other thread must have interrupted the Thread attempting checkout!
java.lang.InterruptedException
at java.lang.Object.wait(Native Method)
at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1465)
at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:644)
at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:554)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutAndMarkConnectionInUse(C3P0PooledConnectionPool.java:758)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:685)
at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:140)
at org.skife.jdbi.v2.DataSourceConnectionFactory.openConnection(DataSourceConnectionFactory.java:34)
at org.skife.jdbi.v2.DBI.open(DBI.java:211)
at org.skife.jdbi.v2.sqlobject.OnDemandHandleDing.getHandle(OnDemandHandleDing.java:36)
at org.skife.jdbi.v2.sqlobject.OnDemandHandleDing.retain(OnDemandHandleDing.java:44)
at org.skife.jdbi.v2.sqlobject.SqlObject.invoke(SqlObject.java:215)
at org.skife.jdbi.v2.sqlobject.SqlObject$2.intercept(SqlObject.java:109)
at org.skife.jdbi.v2.sqlobject.CloseInternalDoNotUseThisClass$$EnhancerByCGLIB$$457b1cb2.getAll(<generated>)
at com.donews.data.util.DBHelper$.getAllPublicTable(DBHelper.scala:183)
at com.donews.data.WebConfig$.<init>(WebConfig.scala:25)
at com.donews.data.WebConfig$.<clinit>(WebConfig.scala)
at com.donews.data.newstreaming.inter.kafkainterface$.kafka2hbase(kafkainterface.scala:68)
at com.donews.data.newstreaming.SdkStreaming$.main(SdkStreaming.scala:99)
at com.donews.data.newstreaming.SdkStreaming.main(SdkStreaming.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.spark.deploy.yarn.ApplicationMaster$$anon$2.run(ApplicationMaster.scala:542)

解决方法:

c3p0.properties放入resources中,如图:

Mysql连接池问题

c3p0.jdbcUrl=jdbc:mysql://mysql-database/user_privileges?useUnicode=true&characterEncoding=utf-8&useSSL=false
c3p0.user=funnel
c3p0.password=1qaz@<2wsx
c3p0.maxIdleTime=10000
c3p0.checkoutTimeout=70000
c3p0.initialPoolSize=5
c3p0.minPoolSize=3
c3p0.maxPoolSize=7

       如果您喜欢我写的博文,读后觉得收获很大,不妨小额赞助我一下,让我有动力继续写出高质量的博文,感谢您的赞赏!!!

Mysql连接池问题