简体   繁体   中英

How to allow the desktop application to access the MySQL DB on a Microsoft server?

I'm building a desktop application using Java and a MySQL Database.

The MySQL Database is supposed to be connected within the desktop application, is stored on the MySQL server on the Microsoft Windows Server 2012 R2 Standard.

I installed the desktop application on two different PCs on the same Network.

(So the DB on the server and the app on the Clients PCs)

The problem is: The desktop application is not working, since the clients PCs can't access the MySQL DB.

My Questions are:

  • How do I allow the desktop application on a client PC to access the MySQL DB on a server?

  • Do I need to change the code that is supposed to connect to the Database on the Microsoft Server?

     public static Connection Connerdb() { try { Class.forName("com.mysql.jdbc.Driver"); Connection con=DriverManager.getConnection("jdbc:mysql://localhost/TestDB",root, " " ); return con; } catch (ClassNotFoundException | SQLException e){ JOptionPane.showMessageDialog(null, e); return null; } } 

You have "localhost" in the JDBC URL. You should use the IP address or the DNS name of the MySQL host.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM