Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problems connecting to remote db thru jdbc app

 
Edmund Castermund
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a linux desktop and a linux server, I want to connect to a mysql db on the server.

here's my code:


on the server end I entered this command in mysql:



I commented out this line in the my.conf line on both the server and desktop so it looks like this..



any ideas?
thanks!
bp
 
Edmund Castermund
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
meant to post the stack trace:

 
James Ward
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please check the following:

1. Are you able to run your java program on the same machine as the MySQL, and connect successfully? If YES, then it means your program works fine. If NO, there is a problem with your program.

2. If you are able to connect succesfully when your java program and MySQL are on the same machine, but not when they are on different machines, then the problem is either with the permissions on MySQL for connecting from a remote machine OR with network connectivity.

Let us know.
 
Edmund Castermund
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think it's an issue with the code...it's a connection issue from one machine to another, hence the socket connection issue.

I was also unable to connect to the remote db by entering from the command line:



correction....to log into a remote db type:


that worked
bp

 
James Ward
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, in that case see the information here (if the problem is in MySQL Configuration):
http://qnatech.wordpress.com/2008/12/04/how-do-i-allowprevent-remote-connection-to-mysql/

Also, try running your java program on the same machine(where MySQL exists), and see if it connects.

Also check the network connectivity.
ping the remote MySQL machine.
Make sure no ports are blocked to/from both machines.
 
Edmund Castermund
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
got it:

* Remote db connection:
* first, give user specific permission on db:
*
* mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
-> ON <dbname>.*
-> TO <username>@<host name>
-> IDENTIFIED BY '<password>';

I edited these 2 lines in the my.cnf file
# skip inernal-locking
# bind-address = 127.0.0.1

then restart msql daemon
* sudo sh /etc/init.d/mysql restart

some links:

http://hashmysql.org/index.php?title=Remote_Clients_Cannot_Connect
http://forge.mysql.com/wiki/Error2003-CantConnectToMySQLServer

bp
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic