0
 Connection con = null;
 try 
     Class.forName("com.mysql.jdbc.Driver");
     con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "");
  catch (Exception ex) 
     System.out.println(ex.getMessage());

return con;

Getting connection link failure message while running jar file from other windows to connect database to other system

Hulk
  • 6,399
  • 1
  • 30
  • 52
Amit Garg
  • 1
  • 4
  • 1
    if you want your java application connect to mysql on other computer, firstly you need to setup a network between them, after that change the `localhost` to the IP of another computer which mysql is running on it, also make sure port, username, and password are correct. https://stackoverflow.com/questions/9289273/how-to-access-the-another-system-mysql-database-through-java-program – Mustafa Poya Nov 10 '20 at 16:25
  • You also forgot braces `{...}` around the `try` block in the code you showed us – Hulk Nov 10 '20 at 16:37
  • @hulk i have added braces in my code but its missing here....can u suggest wat is the issue – Amit Garg Nov 10 '20 at 21:16

0 Answers0