aspose file tools*
The moose likes JDBC and the fly likes problems connecting to remote db thru jdbc app Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "problems connecting to remote db thru jdbc app" Watch "problems connecting to remote db thru jdbc app" New topic
Author

problems connecting to remote db thru jdbc app

Edmund Castermund
Ranch Hand

Joined: May 09, 2007
Posts: 85
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

Joined: May 09, 2007
Posts: 85
meant to post the stack trace:

James Ward
Ranch Hand

Joined: Apr 27, 2003
Posts: 263
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

Joined: May 09, 2007
Posts: 85
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

Joined: Apr 27, 2003
Posts: 263
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

Joined: May 09, 2007
Posts: 85
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problems connecting to remote db thru jdbc app