This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Server connection failure during transaction Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Server connection failure during transaction" Watch "Server connection failure during transaction" New topic
Author

Server connection failure during transaction

Vivek Puthiyonnan
Greenhorn

Joined: Jan 26, 2005
Posts: 18
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)


Vivek P
Rao Raghu
Ranch Hand

Joined: Jan 05, 2007
Posts: 100
Hi Vivek , Raghu here.

jdbc:mysql://64.62.254.61/

Instead of this try localhost:3306/database


RAGHU<br /> <br />"When the going gets tough, the tough get going"
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Server connection failure during transaction
 
Similar Threads
AxisFault: Object reference not set to an instance of an object
new to db connection help needed
java.lang.OutOfMemoryError: Java heap space
Request Entity Too Large
JSP Error