• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ODBC - mysql connectivity

 
Jysh Reey
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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:

2001-2-3
2001-02-03
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...

 
Tim Moores
Bartender
Posts: 2752
38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At which point does ODBC (which the subject talks about) come into play?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15216
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

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.
 
Rob Spoor
Sheriff
Pie
Posts: 20514
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

I'll move this thread to our JDBC forum.
 
Jysh Reey
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic