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.