Skip navigation links

MySQL Forums


Advanced Search

com.mysql.jdbc.CommunicationsException
Posted by: Sedef S ()
Date: November 12, 2008 02:25PM

Hi,

I am getting com.mysql.jdbc.CommunicationsException while trying to connect a remote MySql database.

Client: Windows Vista home ed.
Server: Localhost via UNIX socket,Apache/2.2.3 - Red Hat
DMBS: MySQL 5.0.45
Driver: mysql-connector-java-5.0.8-bin.jar

CODE:
Connection conn = null;
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://web_adr:3306/database_name","user","password");
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("select * from table_name");
while(rs.next()){ /* doing some work here*/ }
rs.close();
st.close();
}
catch (Exception e){
e.printStackTrace();
}
finally{
try{
if (conn != null){conn.close();}
}
catch (Exception e){e.printStackTrace();}
}
}

ERROR code:

com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
java.net.ConnectException
MESSAGE: Connection timed out: connect
STACKTRACE:
java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
....

Here is the part that creates errors:

conn = DriverManager.getConnection("jdbc:mysql://web_adr:3306/database_name","user","password");

--
The DBA says that the problem is related with the driver.

I tried:
- changing properties,
- using dring driver vers. 5.1
- using different combinations of webadr-user-port etc
no result.

Any ideas to solve this problem?

Sedef

Options: ReplyQuote


Subject Written By Posted
com.mysql.jdbc.CommunicationsException Sedef S 11/12/2008 02:25PM
Re: com.mysql.jdbc.CommunicationsException Mark Matthews 11/13/2008 01:05PM
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver tamilselvan ramalingam 11/15/2008 09:52PM


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