Can't connect to MySQL from Java: NullPointerException inside MySQL driver connection logic

前端 未结 3 1529
感情败类
感情败类 2020-11-30 12:54

I\'m trying to connect to a database I created with MySQL in my Java program, but it always fails.

For the sake of example, here is my code:

import j         


        
3条回答
  •  不知归路
    2020-11-30 13:03

    If you call the IP address 127.0.0.1/localhost then you are communicating with the localhost – in principle, with your own computer.This issue also appears when you don't have localhost configured

    For Linux systems

    • Add/Edit "127.0.0.1 localhost" under /etc/hosts if its missing.

    For Windows system

    • Add/Edit under C:windows/system32/drivers/etc/hosts if its missing.

    For more details on localhost

提交回复
热议问题