-1

I can't connect to the local database even if the connection parameters are correct, using jdbc. If I try to connect by terminal or by some client i can connect.

But if I try to connect to remote database it works

this is the error:

Connected to the target VM, address: '127.0.0.1:49986', transport: 'socket' Exception in thread "main" 2019-04-15 12:16:55 FATAL AbstractConnectorDB - Unable to connect to database jdbc:mysql://localhost:3306/my_db?autoReconnect=true&useSSL=false com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up. com.mycompany.database.relational.exceptions.ConnectionFailedException: Fatal error: Unable to connect to db jdbc:mysql://localhost:3306/my_db?autoReconnect=true&useSSL=false @root at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ... ... 17 more Disconnected from the target VM, address: '127.0.0.1:49986', transport: 'socket' 



What could be the problem?

4
  • Possible duplicate of MySQLNonTransientConnectionException: Could not create connection to database server. Attempted reconnect 3 times. Giving up Commented Apr 15, 2019 at 10:32
  • Are you sure about your credentials, the URI used. Can you provide the code that tried to open the connection ? Commented Apr 15, 2019 at 10:32
  • jdbc:mysql://localhost:3306/my_db?autoReconnect=true&useSSL=false Commented Apr 15, 2019 at 10:40
  • Please don't add things like "SOLVED" to your question title. Either accept an answer that helped you or post your own solution as an answer and accept that after the timeout. Commented Apr 15, 2019 at 17:04

2 Answers 2

1

Yes, your connection properties are correct on your PC but not on the VM. Use your PC's IP Address instead.

Sign up to request clarification or add additional context in comments.

4 Comments

even with the address (127.0.0.1) I have the same error
What do you mean "even"? If you try 127.0.0.1 and then 127.0.0.1 you have changed nothing! It is clear that you got the same error! I repeat: Use your PC's IP Address please.
ok, i'm sorry for my english! I tried with 127.0.0.1, 192.168.33.75, 0.0.0.0 and i always get the same error!
Ah ok, i guess the .75 is your target. Unfortunately I have - under this radical changed limitation - not yet an idea whats wrong.
0

The source of the problem was: I was using MySQL version 5 in my POM, but I had MySQL 8 on my computer.
So I completely deleted MySQL from my computer and installed the version I needed

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.