MySql jdbc driver unable to resolve hostname

java.net.UnknownHostException
Javadoc
Thrown to indicate that the IP address of a host could not be determined. @author Jonathan Payne @since JDK1.0
at java.net.Inet6AddressImpl.lookupAllHostAddr
(source)
at java.net.InetAddress$2.lookupAllHostAddr
at java.net.InetAddress.getAddressesFromNameService
(source)
at java.net.InetAddress.getAllByName0
(source)
at java.net.InetAddress.getAllByName
(source)
at java.net.InetAddress.getAllByName
(source)
at com.mysql.jdbc.StandardSocketFactory.connect
(source)
at com.mysql.jdbc.MysqlIO.<init>
(source)
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException
Javadoc
An exception to represent communications errors with the database. Attempts to provide 'friendler' error messages to end-users, including last time a packet was sent to the database, what the client-timeout is set to, and whether the idle time has been exceeded.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0
(source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance
(source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance
(source)
at java.lang.reflect.Constructor.newInstance
(source)
at com.mysql.jdbc.Util.handleNewInstance
(source)
at com.mysql.jdbc.SQLError.createCommunicationsException
(source)
at com.mysql.jdbc.MysqlIO.<init>
(source)
14 frames hidden

Typical Exception Messages

  1. Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
  2. 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.
  3. 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.
  4. 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.
  5. Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: 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.
  6. Unable to start embedded Tomcat
  7. Cannot create PoolableConnectionFactory (Could not create connection to database server. Attempted reconnect 3 times. Giving up.)
  8. Failed to load ApplicationContext

Origin

NativeConstructorAccessorImpl.newInstance() has thrown a CommunicationsException

java.net.UnknownHostException
9 frames hidden
sun.reflect.NativeConstructorAccessorImpl.newInstance
3Web pages

Similar

Specific cases

Solution

rahsan, 3 months ago

There are quite a few reasons for this type of error. Please read this answer for more details.

External results for this pattern (3)

  1. MrKiller01via GitHub1 year ago
    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.
    Show stack trace
  2. 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.
    Show stack trace