I'm having trouble connecting to my database. I think there is a setting somewhere that I don't know about and needs to be changed. I have some really basic code here:
public static void main(String[] args) { try { Connection con = DriverManager.getConnection("jdbc:mysql://IP:3306/TABLENAME?autoReconnect=true","USERNAME", "PASSWORD"); con.close(); } catch(Exception e) { e.printStackTrace(); } } Obviously with the login info. And it causes this error:
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up. Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: 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. Caused by: java.net.ConnectException: Connection refused I've looked through about 10 different posts about the same problem and tried their solutions and still couldn't get it to work.
MySql5.7wanted to useTLSv1.1, which has been blocked by theOpenJDK v11.0.11release. To allow it again, you can removeTLSv1.1from the list atjdk.tls.disabledAlgorithmsinopenjdk64-11.0.11/conf/security/java.security. This is one possible solution to one possible cause of this problem. Please reopen the question.