com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Posted by: adul adul
Date: February 25, 2009 07:17AM

import java.sql.Connection;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.DriverManager;
public class DataBase
{
public static void main(String args[])
{
Connection con = null;
Statement stmt = null;
ResultSet res = null;

try
{

Class.forName("com.mysql.jdbc.Driver");


con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql", "", "");

stmt = con.createStatement();
res = stmt.executeQuery("select * from user");

while(res.next())
{

System.out.println(res.getString(1)+"\t"+res.getString(2));
}
}
catch(Exception e)
{

System.out.println(e);
e.printStackTrace();
}
finally
{

try
{

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

System.out.println(e);
} } } }

I am getting this error.. please let me know hw to correct this.



Edited 1 time(s). Last edit at 02/25/2009 07:22AM by adul adul.

Options: ReplyQuote


Subject
Written By
Posted
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
February 25, 2009 07:17AM


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

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.