Here i hav enclosed my Java program that has mysql as backend...
am using ubuntu... when i press connect button after specifying the details, in Mysql Administrator, it displays the server is running... this java prog of mine is complied and is without any error... but when i type java -cp .:/usr/share/java/mysql-connector-java-5.1.10.jar Test in terminal i receive the following error.....!!
Enter a date:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
my sql table description:
could not find whats wrong with the connection..... somebody please help...
due to this my college project is in stagnate condition...
By default, MySQL does not allow access from remote computers. If your MySQL server is running on a different computer then where you are running your program on, then you have to enable remote connections on the MySQL server.
In line 20 of your code, try using "localhost:3306" instead of "jeyasri-desktop:3306". When you specify an explicit hostname ("jeyasri-desktop") then MySQL might treat it as a remote connection and deny it.
It most certainly will. The MySQL user table has a column for the host that the connections can come from. Sometimes there is a catch-all there, but by default Ubuntu only has "localhost" for the root user. If the connecting host does not equal one of the allowed host for the user, and there's no catch-all, then you simply will not be able to connect.
First of all thanks for everyone who made a response..
@Tim Moores : Am sorry, its JDBC...
@Jesper de Jong, @Rob Spoor : No am running Mysql in the same computer... i have created a connection in the Mysql Administrator with the host name "jeyasri-desktop"... changing it into localhost also results the same... i once read in a forum that the IP address may also be a problem for it..it said there are case where the default IPaddress to be 127.0.0.1... while creating connection Mysql Administrator showed the IP address as 192.168.1.2... am i supposed to set this somewhere ?