Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Server connection failure during transaction

 
Vivek Puthiyonnan
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i'm using mysql database with my application. But when i try to do database transaction, its giving "java.sql.SQLException: Server connection failure during transaction." error....

please help me out of this ..

My jdbc code is as follows ::]my jdbc code is as follows ::

<%@ page language="java" contentType="text/html" %>
<%@ page import="java.sql.*,java.io.*" %>



<%
Connection con=null;
ResultSet res=null;

try{
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
con=DriverManager.getConnection("jdbc:mysql://64.62.254.61/database?user=username&password=mypassword&autoReconnect=true");
PreparedStatement pst=con.prepareStatement("INSERT INTO testtable VALUES (?,?)");

//System.out.println("\n Entering");

pst.setString(1,request.getParameter("name"));
pst.setString(2,request.getParameter("company"));
pst.executeUpdate();

//System.out.println("***Data entered Successfully***");

con.close();
}catch(Exception e){

e.printStackTrace(new PrintWriter(out));
}


%>




The Error Stack Trace i got is as follows :::


java.sql.SQLException: Server connection failure during transaction. Due to underlying exception: 'java.net.SocketException: java.net.ConnectException: Connection timed out: connect'. ** BEGIN NESTED EXCEPTION ** java.net.SocketException MESSAGE: java.net.ConnectException: Connection timed out: connect STACKTRACE: java.net.SocketException: java.net.ConnectException: Connection timed out: connect at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:151) at com.mysql.jdbc.MysqlIO.(MysqlIO.java:280) at com.mysql.jdbc.Connection.createNewIO(Connection.java:1895) at com.mysql.jdbc.Connection.(Connection.java:437) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:268) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at org.apache.jsp.jsp.inserting_jsp._jspService(inserting_jsp.java:58) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:425) at org.apache.coyote.ajp.AjpAprProtocol$AjpConnectionHandler.process(AjpAprProtocol.java:452) at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1285) at java.lang.Thread.run(Unknown Source) ** END NESTED EXCEPTION ** Attempted reconnect 3 times. Giving up. at com.mysql.jdbc.Connection.createNewIO(Connection.java:1963) at com.mysql.jdbc.Connection.(Connection.java:437) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:268) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at org.apache.jsp.jsp.inserting_jsp._jspService(inserting_jsp.java:58) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) at javax.servlet.http.HttpServlet.service(HttpServlet.java:802) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:425) at org.apache.coyote.ajp.AjpAprProtocol$AjpConnectionHandler.process(AjpAprProtocol.java:452) at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1285) at java.lang.Thread.run(Unknown Source)
 
Rao Raghu
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vivek , Raghu here.

jdbc:mysql://64.62.254.61/

Instead of this try localhost:3306/database
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic