1

I want to connect a MySQL database in other application through static ip or port no.

What is run own application on other pc nothing no result empty. When I put this address own other pc this link correctly work http://192.168.137.1:81/phpmyadmin access phpmyadmin database.

I used in connection string this ip or port 92.168.137.1:81

My code

import java.sql.Connection;
import java.sql.DriverManager;

/**
 *
 * @author VAISAL
 */
public class ConnectionDB {
 Connection koneksi=null;
public static String host="192.168.137.1:81";


public static Connection koneksiDb(){
    try
    {
        Class.forName("com.mysql.jdbc.Driver");
        Connection filekoneksi = DriverManager.getConnection("jdbc:mysql://"+host+"/sale","ultronhouse","qwertyuiop");
        System.out.println("Connection Success");
        return filekoneksi;
    }
    catch (Exception e){
        System.out.println(e.getMessage()+"Connection error");
        return null;
    }
}   
}
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • PHPMyAdmin is **not** a MySQL database server. It is a webapplication to access a MySQL database using a GUI. PHPMyAdmin itself connects to a MySQL database server, and your Java application needs to connect to that MySQL server as well. It cannot talk to PHPMyAdmin. You need to use the IP address and port of your MySQL server. – Mark Rotteveel Apr 04 '19 at 08:37
  • @ Mark Rotteveel thanks for . i want to make an center database and then access this central databse other computer LAN or IP port. – Naveed Islam Apr 04 '19 at 09:26
  • That doesn't matter, you still need to connect to your MySQL server and not to PHPMyAdmin (and make sure your MySQL server is configured to accept external connections, etc). – Mark Rotteveel Apr 04 '19 at 11:04
  • @ Mark Rotteveel inside xampp server under appache also available mysql server database and mysql server in xammp run on this port 3306. i am using xampp server 3.3.2 and inside this mysql server also available. – Naveed Islam Apr 04 '19 at 12:01
  • @ Mark Rotteveel please join me on skype and configer this please my skype id naveedali8844 – Naveed Islam Apr 04 '19 at 12:02
  • No, sorry. This is basic configuration covered in the MySQL documentation + the duplicate link. – Mark Rotteveel Apr 04 '19 at 12:13
  • error after compiling , Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.Connection error – Naveed Islam Apr 04 '19 at 12:44
  • See https://stackoverflow.com/questions/6865538/solving-a-communications-link-failure-with-jdbc-and-mysql and its linked duplicate – Mark Rotteveel Apr 04 '19 at 12:51

0 Answers0