Java 如何避免c3po中的连接超时?
如何避免c3p0连接中的连接超时错误 我已设置TestConnectionOnCheckout=trueJava 如何避免c3po中的连接超时?,java,mysql,c3p0,Java,Mysql,C3p0,如何避免c3p0连接中的连接超时错误 我已设置TestConnectionOnCheckout=true PreferredTestQuery=选择1 但是,不是固定的。扔 com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:通信链路故障 cpds.setMinPoolSize(3); cpds.setMaxPoolSize(10); cpds.setIdleConnectionTestP
PreferredTestQuery=选择1
但是,不是固定的。扔 com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:通信链路故障
cpds.setMinPoolSize(3);
cpds.setMaxPoolSize(10);
cpds.setIdleConnectionTestPeriod(29);
cpds.setTestConnectionOnCheckout(true);
cpds.setPreferredTestQuery("SELECT 1");
我的MySQL数据库超时是30秒。我需要每29秒发送一次db呼叫,或者在连接超时时重新连接。
怎么做 评论
//cpds.setMinPoolSize(3);
//cpds.setMaxPoolSize(10);
//cpds.setIdleConnectionTestPeriod(29);
//cpds.setTestConnectionOnCheckout(true);
//cpds.setPreferredTestQuery("SELECT 1");
并添加了TestConnectionOnCheckin、TestConnectionOnCheckout和MaxConnectionAge
cpds.setTestConnectionOnCheckin(true);
cpds.setTestConnectionOnCheckout(false);
cpds.setMaxConnectionAge(28);