java - Tomcat Configuration using DBCP -


we getting communicationsexception (from dbcp) after iding while (a few hours). error message (in exception) @ end of question - dont see wait_timeout defined in of configuration files. (where should look? somewhere out of tomcat/conf directory?).

secondly, suggested exception, 1 put "connector/j connection property 'autoreconnect=true'"? here resource definition in file conf/context.xml in tomcat set up:

<resource name="jdbc/tomcatresourcename" auth="container" type="javax.sql.datasource"            maxactive="100" maxidle="30" maxwait="10000"            removeabandoned="true" removeabandonedtimeout="60" logabandoned="true"            username="xxxx" password="yyyy"            driverclassname="com.mysql.jdbc.driver"            url="jdbc:mysql://127.0.0.1:3306/dbname?autoreconnect=true"/> 

thirdly, why jvm wait till call executequery() throw exception? if connection has timed out, getconnection method should throw exception, shouldn't it? section of source code talking about:

        try {                 conn = getconnection (true);                 stmt = conn.createstatement (resultset.type_scroll_insensitive,                                                 resultset.concur_read_only);                 rset = stmt.executequery (bquery);                 while (rset.next()) {                      .... 

finally, here 1st few lines of stack trace...

com.mysql.jdbc.exceptions.jdbc4.communicationsexception: last packet received server 84,160,724 milliseconds ago.  last packet sent server 84,160,848 milliseconds ago. longer server configured value of 'wait_timeout'. should consider either expiring and/or testing connection validity before use in application, increasing server configured values client timeouts, or using connector/j connection property 'autoreconnect=true' avoid problem. @ sun.reflect.nativeconstructoraccessorimpl.newinstance0(native method) @ sun.reflect.nativeconstructoraccessorimpl.newinstance(nativeconstructoraccessorimpl.java:57) @ sun.reflect.delegatingconstructoraccessorimpl.newinstance(delegatingconstructoraccessorimpl.java:45) @ java.lang.reflect.constructor.newinstance(constructor.java:532) @ com.mysql.jdbc.util.handlenewinstance(util.java:406) @ com.mysql.jdbc.sqlerror.createcommunicationsexception(sqlerror.java:1074) @ com.mysql.jdbc.mysqlio.send(mysqlio.java:3291) @ com.mysql.jdbc.mysqlio.sendcommand(mysqlio.java:1938) @ com.mysql.jdbc.mysqlio.sqlquerydirect(mysqlio.java:2107) @ com.mysql.jdbc.connectionimpl.execsql(connectionimpl.java:2642) @ com.mysql.jdbc.connectionimpl.execsql(connectionimpl.java:2571) @ com.mysql.jdbc.statementimpl.executequery(statementimpl.java:1451) @ org.apache.tomcat.dbcp.dbcp.delegatingstatement.executequery(delegatingstatement.java:208) 

these reasons of thinking "forget dbcp, may dependent on ide configurations , under-the-hood magic drivermanager.getconnection(...) may more reliable". comments on that? thank insights, - ms

since dbcp keeps returned mysql connections open upcoming connection requests, fall victims mysql server timeout.

dbcp has number of features can (can used starting tomcat 5.5 iirc).

validationquery="select 1" testonborrow="true" 

the validation makes sure connection valid before returning webapp executing 'borrow' method. flag of course, enables feature.

if timeout (8 hours believe) elapsed , connection dead, new connection tested (if there none anymore, created) , provided webapp.

other possible approaches:

  1. use testwhileidle="true" dbcp in resource settings check idle connections before effective request detected.

  2. use 'connectionproperties' harden mysql connection (e.g. autoreconnect/autoreconnectforpools=true)


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -