0

Maybe the question is duplicated, but I didn't find an answer on the other similar posts here in StackOverflow. My question is simple : I have a java application on a computer A, I have access to my localhost server with this app using JDBC:

con=DriverManager.getConnection("jdbc:mysql://127.0.0.1/applicationrh?zeroDateTimeBehavior=convertToNull&autoReconnect=true&characterEncoding=UTF-8&characterSetResults=UTF-8","root","");

the connection to my localhost database stand when I use 127.0.0.1 or localhost in JDBC but I get an error when I use my computer IP.

con=DriverManager.getConnection("jdbc:mysql://192.168.1.173/applicationrh?zeroDateTimeBehavior=convertToNull&autoReconnect=true&characterEncoding=UTF-8&characterSetResults=UTF-8","root","");

Error :

error Could not create connection to database server. Attempted reconnect 3 times. Giving up.

I want to access to my localhost database on the computer 'A' from a computer 'B'on the same network, I modified the httpd.conf to allow access from others IPs and the connection stands when I type the computer A IP on the computer 'B' navigator , but its the same problem with JDBC.

Edit 1 : I can't find the bind_address line on my.ini file to add more ips. I'am using wamp 3.1.0 and mysql 5.7.19

Edit 2 : By desactivating temporary my antivirus (avira) now i can access to my db from the computer 'A' by using the ip adress. still can't do this on the computer 'B'

Hamdi Gatri
  • 101
  • 2
  • 12
  • 2
    i guess you need to mention port as well – Nidhi257 Oct 24 '17 at 09:41
  • 1
    Have you tried to connect to your DB using `mysql` command or mysql workbench ? I don"t think your problem is related to your java code. – Akli REGUIG Oct 24 '17 at 09:44
  • In MySQL you need to create a user with rights on that IP (GRANT). The firewall on the server must be opened for the database port. A bit of search should give an example. – Joop Eggen Oct 24 '17 at 09:45
  • @Nidhi257 i did but it showed me the same error – Hamdi Gatri Oct 24 '17 at 09:58
  • the httpd file has nothing to do with this problem. The mysql instance might not allow connections from other machines or the port 3306 is blocked for some reason (firewall etc). – f1sh Oct 24 '17 at 09:58
  • 2
    Possible duplicate of [MySQL root access from all hosts](https://stackoverflow.com/questions/11223235/mysql-root-access-from-all-hosts) – f1sh Oct 24 '17 at 09:59
  • @f1sh how to check if the firewall is blocking the access , i have avira as an antivirus for the two machines, and i'am working on windows 10. – Hamdi Gatri Oct 24 '17 at 10:20
  • @f1sh thank you now i'am making progress, i desactivate temporary my antivirus and now i can access to mly DB on the computer 'A' using the ip adress of the computer, still can't do this from the computer 'B' – Hamdi Gatri Oct 24 '17 at 10:27

0 Answers0