在我的程序以 3cp0 作为我的连接池运行 30 分钟左右后,我收到以下异常。
这是错误:
[java] INFO [Timer-0] (BasicResourcePool.java:1392) - A checked-out resource is overdue, and will be destroyed: com.mchange.v2.c3p0.impl.NewPooledConnection@eaecb09
[java] The last packet successfully received from the server was 375,017 milliseconds ago. The last packet sent successfully to the server was 9 milliseconds ago.
[java] Exception in thread "main" java.lang.NullPointerException
[java] at com.mytest.myorg.MyProg.MyProgRunner.main(MyProgRunner.java:104)
我正在像这样设置我的游泳池:
ComboPooledDataSource cpds = new ComboPooledDataSource();
cpds.setDriverClass( "com.mysql.jdbc.Driver" ); //loads the jdbc driver
cpds.setJdbcUrl( "jdbc:mysql://"+hostname+"/"+database );
cpds.setUser(username);
cpds.setPassword(password);
cpds.setMinPoolSize(5);
cpds.setAcquireIncrement(5);
cpds.setMaxPoolSize(15);
cpds.setAutoCommitOnClose(true);
cpds.setIdleConnectionTestPeriod(300);
cpds.setMaxStatements(180);
cpds.setNumHelperThreads(20);
cpds.setUnreturnedConnectionTimeout(300);
我有 100 个线程来抓取页面,然后有 15 个数据库线程将结果插入到我的数据库中。如果抓取任务需要超过 20 秒,我会终止线程。任何想法为什么数据库连接池会死掉?
谢谢