If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Why 'localhost' works but '192.168.111.12' does not work

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-02-08, 09:57
cy163 cy163 is offline
Registered User
 
Join Date: Apr 2007
Posts: 127
Why 'localhost' works but '192.168.111.12' does not work

Hello ALL,

I install MySQL on a Linux server (ip:192.168.111.12), and use following Java code to create a connection to the server via mysql-connector-J.
Code:
String url="jdbc:mysql://localhost/QueryTask_Answer";
//String url="jdbc:mysql://192.168.111.12/QueryTask_Answer";
String databasesuser="root";
String password="";
Class.forName("com.mysql.jdbc.Driver");
con=Driver.Manager.getConnection(url, databaseuser, password);
.................
..............
This code works well when it runs locally on the machien (ip:192.168.111.12), with the following line

Code:
String url="jdbc:mysql://localhost/QueryTask_Answer";
but not when replace the line with the following line
Code:
String url="jdbc:mysql://192.168.111.12/QueryTask_Answer";
It is strange that the two cases almost the same except the experssion of ip address. I do not know why.

Last edited by cy163; 09-02-08 at 10:05.
Reply With Quote
  #2 (permalink)  
Old 09-02-08, 10:04
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
check what permissions have been granted to that user for what ip addresses.
examine any error messages and see what they are trying to tell you.

after that I'd suggest we move this post to the JAVA forum, as you are probably more likely to resolve such JAVA problems there
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On