• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

com.mysql.jdbc.exceptions.jdbc4.communicationsexception communications link failure

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm getting this exception. Actually i'm running a loop and for many iterations its working fine but after around 25 seconds I get this exception for every iteration.

I am using jdk 1.5 , Mysql freeware 5.0 , OS is windows Vista.




Can anyone help me with the issue?

Thanks,
Aditya
 
Adi Kulkarni
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

Any pointers ?

~Aditya
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please print the full stack trace with the code which actually throwing the exception, because you said the problem is within a loop and I don't find any loop code?
Between, what is the "connection_timeout' environment variable set to ? also see the max client connection allowed setting in MySQL.
 
Adi Kulkarni
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rohan,

Following is the stack trace. Since DB is being used for comparison for every iteration, the loop comes into picture. So the thing is that the DB query is being executed fine for some iterations after which I get this exception

Cannot connect to database server
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was 1,252,319,692,146 milliseconds ago. The last packet sent successfully to the server was 0 milliseconds ago.
at sun.reflect.GeneratedConstructorAccessor10.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2214)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:773)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
at sun.reflect.GeneratedConstructorAccessor6.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:352)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.bt.LibraryDataProvider.compareUsingLibrary(LibraryDataProvider.java:27)
at com.bt.CSVFileProcessor.CompareAndWriteToFile(CSVFileProcessor.java:472)
at com.bt.CSVFileProcessor.processBufferData(CSVFileProcessor.java:428)
at com.bt.CSVFileProcessor.recognitionEngine(CSVFileProcessor.java:83)
at com.bt.MainProcessCall.main(MainProcessCall.java:12)
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The driver was unable to create a connection due to an inability to establish the client portion of a socket.

This is usually caused by a limit on the number of sockets imposed by the operating system. This limit is usually configurable.

For Unix-based platforms, see the manual page for the 'ulimit' command. Kernel or system reconfiguration may also be required.

For Windows-based platforms, see Microsoft Knowledge Base Article 196271 (Q196271).
at sun.reflect.GeneratedConstructorAccessor10.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:341)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2137)
... 15 more
Caused by: java.net.BindException: Address already in use: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:253)Entering compare and write
Buffer size 2
Exiting compare and write

at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:290)
... 16 more
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Adi Kulkarni wrote:Hi Rohan,


Kulkarni, "Rohan" is part of my surname

I don't know how you're getting the connection, Its useless to comment anything unless you provide the "actual" code which is responsible for the exception(I think, its a loop code)

FYI,
And the exception itself explain its cause,

Adi Kulkarni wrote:
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The driver was unable to create a connection due to an inability to establish the client portion of a socket.

This is usually caused by a limit on the number of sockets imposed by the operating system. This limit is usually configurable.

For Unix-based platforms, see the manual page for the 'ulimit' command. Kernel or system reconfiguration may also be required.

For Windows-based platforms, see Microsoft Knowledge Base Article 196271 (Q196271).

Caused by: java.net.BindException: Address already in use: connect

 
Adi Kulkarni
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks SAGAR
 
Adi Kulkarni
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


This is the loop which calls that method
 
Sagar Rohankar
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now, that's loop code, by any chance, doesn't hint any thing related to db connection.
Between, when I Google the exception, I found plenty hits discussed the same issue, so Google:
The driver was unable to create a connection due to an inability to establish the client portion of a socket.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found a solution that worked for me. (sorry for my english.... I m french)

I was looking for a solution all the day for using JDBC connector with mysql and eclipse. With the last version of JDBC connector 5.1... it does not work so after long hours I decided to change the version of the connector to 5.08 and then I don't have any more problem. It works fine. We are lot experiencing this problem so if it can help à would be pleased.

bye

glaudy
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

leglaude leglaudy wrote:I found a solution that worked for me. (sorry for my english.... I m french)

I was looking for a solution all the day for using JDBC connector with mysql and eclipse. With the last version of JDBC connector 5.1... it does not work so after long hours I decided to change the version of the connector to 5.08 and then I don't have any more problem. It works fine. We are lot experiencing this problem so if it can help à would be pleased.

bye

glaudy



Hello, I have the same problem, I am looking since 3 days for a solution to activate the connector but no issue ...
I tried the 5.0.8 version and it does not work neither
I am working with

thanks for your help
Marwa
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you're running multiple instances of MySQL, make sure the instance you're referencing is up and running.
 
m kanso
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Scott Manno wrote:If you're running multiple instances of MySQL, make sure the instance you're referencing is up and running.



what is instance ? I am not a database expert so please be more specified and clear,
thanks for the reply
 
Scott Manno
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

m kanso wrote:

Scott Manno wrote:If you're running multiple instances of MySQL, make sure the instance you're referencing is up and running.



what is instance ? I am not a database expert so please be more specified and clear,
thanks for the reply



Two copies. For instance, if you have one (or more) standalone install of MySQL, and/or you're also using something like wampserver, which installs its own copy. Make sure you're looking at the port that corresponds to the install (and that the database is in that copy).
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am having same problem.Application and database both are on Linux Machine .Please help

Code of java connection class is :
//Class Code
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.net.ssl.HttpsURLConnection;

@WebService(serviceName = "NewWebService")
public class NewWebService {

private final String USER_AGENT = "Mozilla/5.0";

@WebMethod(operationName = "isValidUser")
public String isValidUser(@WebParam(name = "phone") String phone, @WebParam(name = "pass") String upass)
{
String mesg = "";
Connection con=null;

try {
con = ConnectionProvider.getCon();
String query = "select * from customer where mobile_phone='" + phone + "' and password='" + upass + "'";
PreparedStatement ps = con.prepareStatement(query);
ResultSet rs = ps.executeQuery();
System.out.println("query----" + query);
boolean status = rs.next();
if (status) {
con = ConnectionProvider.getCon();
String query1 = "select verified from customer where mobile_phone='" + phone + "' ";
PreparedStatement ps1 = con.prepareStatement(query1);
ResultSet rs1 = ps1.executeQuery();
String str = "";
while (rs1.next()) {
str = rs1.getString(1);
}
if (str.equalsIgnoreCase("y")) {
mesg = "you have successfully Login";
} else if (str.equalsIgnoreCase("n")) {
mesg = "please comfirm your account first";
}
} else {
mesg = "UserName or Pasword Wrong";
}

System.out.println("status----" + status);
//java.sql.Driver mySqlDriver = DriverManager.getDriver("jdbc:mysql://202.164.41.156:3306/");
//DriverManager.deregisterDriver(mySqlDriver);

} catch (Exception ex) {
System.out.println("Execption uis : " + ex);
}
return mesg;
}
}

//End class Code

//Error Log from Apache
Execption uis : com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 57,221,771 milliseconds ago. The last packet sent successfully to the server was 57,221,784 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.

//
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic