Unable to connect to remote mysql database using IP Address
Dear friends,
I am Kranthi. I am new to java programming. I am having the following problem. Can any one of you help me..??
I am using Xamplite 1.7.2
My Xampp is running on IP: 192.168.1.16 and port: 3306 in our office network.
I have written one java program in order to connect to the IP: 192.168.1.15:3306
I am have written my program like this:
public class DataSource {
private static Connection con;
public static Connection getConnection(){
try{
Class.forName("com.mysql.jdbc.Driver").newInstance ();
con = DriverManager.getConnection("jdbc:mysql://192.168.1.15:3306/school","root","");
}catch(Exception e){
System.out.println("Exception: "+e);
}
return con;
}
}
Output:
At the end it is returning null instead of connection object. Why it is happening. On the remote system i am having username: root and password is not specified. And, my connection program is like this....!!
Can any of you tell me... why it is happening..!!
Please help mee..!!
Kranthi
I tried with out username and password
Dear friend,
I have tried to connect without providing username and password, i.e with one parameter.
And, i have modified user privileges in phpmyadmin now it is connecting if i provide my system ip instead of localhost.
But, again i am unable to connect from the different system.
my modified code is like this:
public class DataSource {
private static Connection con;
public static Connection getConnection(){
try{
Class.forName("com.mysql.jdbc.Driver").newInstance ();
con = DriverManager.getConnection("jdbc:mysql://192.168.1.15:3306/school","root",""); // But i can not connect to ip: 192.168.1.16
}catch(Exception e){
System.out.println("Exception!!"+e);
}
return con;
}
}