Do or Die
Posted by: Karan Rajput
Date: May 17, 2015 12:18PM

Hi,

I am getting the below Error ,when i am connecting to MYSQL.
To reproduce the error, next day I open the website on the index page and try to login into website and then I get the error.


com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: No operations allowed after connection closed.Connection was implicitly closed due to underlying exception/error:

** BEGIN NESTED EXCEPTION **

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException MESSAGE: Communications link failure

Last packet sent to the server was 4975 ms ago.

STACKTRACE:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

Last packet sent to the server was 4975 ms ago. at
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at
java.lang.reflect.Constructor.newInstance(Constructor.java:526) at
com.mysql.jdbc.Util.handleNewInstance(Util.java:406) at
com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074) at
com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2985) at
com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2871) at
com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3414) at
com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936) at
com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060) at
com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2536) at
com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2465) at
com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1383) at
com.erp.Beans.MarketingDashBoardBean.getMonthDiff(MarketingDashBoardBean.java:50) at
org.apache.jsp.MarketingDashBoardPage_jsp._jspService(MarketingDashBoardPage_jsp.java:586) at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304) at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224) at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169) at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929) at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405) at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964) at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515) at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302) at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at
java.lang.Thread.run(Thread.java:745)

Caused by: java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost. at
com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2431) at
com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2882) ... 31 more






My Code is as below

int sr=1;
String comid=session.getAttribute("CompanyMasterId").toString();
rs=mkd.getCompanyList(CompanyMasterId,code);
System.out.println("2");
while(rs.next()){

rs.getString("ProspCustName");

}



and getCompanyList method is as below

public ResultSet getCompanyList(String CompanyMasterId,String code) throws Exception{
try{
con=ConnectionProvider.getCon();
String sqlList="select ProspCustName,ContactPerson,Address,City from "+CompanyMasterId+"followup where MarketingRepcode='"+code+"' AND ProspCustName <> '-' Group By ProspCustName";
ps=con.prepareStatement(sqlList);
rs=ps.executeQuery(sqlList);

}catch(Exception e){
}
System.out.println("here");
return rs;
}







Please help me this Question is most most imp for me

Options: ReplyQuote


Subject
Written By
Posted
Do or Die
May 17, 2015 12:18PM
May 20, 2015 12:17PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.