Victor Ikenna Victor Ikenna - 1 month ago 20
MySQL Question

Java Remote Connection

Assuming I have this Connection String on my local host:

public static Connection ConnectDB(){
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/supermarket", "root","");
return con;
}


When I am trying to Connect to this system from another. What should I change to access the database?

Say my IP Address on the system is : 192.168.137.1

Answer

your statement would become

Connection con = DriverManager.getConnection("jdbc:mysql://<IP Address>:<Port>/supermarket", "root",""); 

Use appropriate IP and Portnumber

Connection con = DriverManager.getConnection("jdbc:mysql://192.168.137.1:6036‌​/supermarket", "root","");