java - Communication to DB error in production -


i did web app deploy in production. after several hours (looks 8 hour), can't communicate db.

here connect.java

package util;  import java.sql.connection; import java.sql.drivermanager; import javax.xml.ws.response;  public class connect {     public static connection connection = null;      public static connection getconnection() {         if (connection != null) {             return connection;         } else {             string driver = "com.mysql.jdbc.driver";             string url = "jdbc:mysql://localhost/dbprk?autoreconnect=true&useunicode=true&characterencoding=utf8";             string username = "prk";             string password = "prk";              try {                 class.forname(driver);                 connection = drivermanager.getconnection(url, username, password);             } catch (exception e) {                 system.out.println("error");             }             return connection;         }     } } 

and here error message got tomcat log:

com.mysql.jdbc.communicationsexception: communications link failure due underlying exception:   ** begin nested exception **   java.net.socketexception message: software caused connection abort: socket write error  stacktrace:  java.net.socketexception: software caused connection abort: socket write error     @ java.net.socketoutputstream.socketwrite0(native method)     @ java.net.socketoutputstream.socketwrite(socketoutputstream.java:113)     @ java.net.socketoutputstream.write(socketoutputstream.java:159)     @ java.io.bufferedoutputstream.flushbuffer(bufferedoutputstream.java:82)     @ java.io.bufferedoutputstream.flush(bufferedoutputstream.java:140)     @ com.mysql.jdbc.mysqlio.send(mysqlio.java:2616)     @ com.mysql.jdbc.mysqlio.send(mysqlio.java:2547)     @ com.mysql.jdbc.mysqlio.sendcommand(mysqlio.java:1512)     @ com.mysql.jdbc.mysqlio.sqlquerydirect(mysqlio.java:1622)     @ com.mysql.jdbc.connection.execsql(connection.java:2370)     @ com.mysql.jdbc.connection.execsql(connection.java:2297)     @ com.mysql.jdbc.statement.executequery(statement.java:1183)     @ controller.getallclients.processrequest(getallclients.java:39)     @ controller.getallclients.doget(getallclients.java:73)     @ javax.servlet.http.httpservlet.service(httpservlet.java:617)     @ javax.servlet.http.httpservlet.service(httpservlet.java:717)     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:290)     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206)     @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:233)     @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:191)     @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:127)     @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:102)     @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:109)     @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:298)     @ org.apache.coyote.http11.http11processor.process(http11processor.java:852)     @ org.apache.coyote.http11.http11protocol$http11connectionhandler.process(http11protocol.java:588)     @ org.apache.tomcat.util.net.jioendpoint$worker.run(jioendpoint.java:489)     @ java.lang.thread.run(thread.java:745)   ** end nested exception **       @ com.mysql.jdbc.mysqlio.send(mysqlio.java:2634)     @ com.mysql.jdbc.mysqlio.send(mysqlio.java:2547)     @ com.mysql.jdbc.mysqlio.sendcommand(mysqlio.java:1512)     @ com.mysql.jdbc.mysqlio.sqlquerydirect(mysqlio.java:1622)     @ com.mysql.jdbc.connection.execsql(connection.java:2370)     @ com.mysql.jdbc.connection.execsql(connection.java:2297)     @ com.mysql.jdbc.statement.executequery(statement.java:1183)     @ controller.getallclients.processrequest(getallclients.java:39)     @ controller.getallclients.doget(getallclients.java:73)     @ javax.servlet.http.httpservlet.service(httpservlet.java:617)     @ javax.servlet.http.httpservlet.service(httpservlet.java:717)     @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:290)     @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206)     @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:233)     @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:191)     @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:127)     @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:102)     @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:109)     @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:298)     @ org.apache.coyote.http11.http11processor.process(http11processor.java:852)     @ org.apache.coyote.http11.http11protocol$http11connectionhandler.process(http11protocol.java:588)     @ org.apache.tomcat.util.net.jioendpoint$worker.run(jioendpoint.java:489)     @ java.lang.thread.run(thread.java:745) 

btw use pure jsp no framework. appreciate.

this problem may occur in following cases:

  1. when trying many db connections.
  2. when db connection idle long time.

so, in program try close connection after usage, , new connection.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -