I am trying to connect to MySQL from JDBC via **localhost**. But the connection fails. In the exception, I see that JDBC is trying to connect to **127.0.0.1**

```
    String connectionString = "";
    try {
        loadProperties();
        Class.forName("com.mysql.jdbc.Driver");
        // Setup the connection with the DB
        connectionString = "jdbc:mysql://" + properties.getProperty("host") + "/" + properties.getProperty
                ("database") + "?user=" + properties.getProperty("user") + "&password=" + properties
                .getProperty
                        ("password");
        connect = DriverManager
                .getConnection(connectionString);
        logger.debug("Connected to " + properties.getProperty("host"));
    } catch (Exception e) {
        logger.error("Database Connection failed with connection string - " + connectionString,e);
    }

```

From the log:

```
Database Connection failed with connection string - jdbc:mysql://localhost/testdb?user=testuser&password=testpass

java.sql.SQLException: Access denied for user 'testuser'@'127.0.0.1' (using password: YES)

```

Why is it replacing localhost with 127.0.0.1? I have configured login only for localhost.