I have two applications using JDBC and MySQL opened in Eclipse Neon.
One application has:
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/mydatabase","root","password");
The other application has:
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/mydatabase","root","password");
I have run the two applications one after another in eclipse several times. The first application can run to connect to and read and write the database.
The second application always gives an exception at the call to DriverManager.getConnection()
method
java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
I googled the error, and https://stackoverflow.com/a/12574926/9119247 seems to say it is my network adapter problem. But if it is, why does it work for one application but not the other, however I run them in whichever order?