com.mysql.jdbc.CommunicationsException
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
Sorry, you can't reply to this topic. It has been closed.
© 1995-2008 MySQL AB, 2008- Sun Microsystems, Inc.