简体   繁体   English

UnknownHostException:连接到数据库服务器时

[英]UnknownHostException: while connecting to database server

I am trying to host MySQL database on 1nd1.com. 我正在尝试在1nd1.com上托管MySQL数据库。 I have created a database with few tables. 我创建了一个只有几个表的数据库。 Getting below error while connecting to 1and1 database from java application. 从Java应用程序连接到1and1数据库时出现以下错误。

When pinging from the command prompt using "ping hostname" command, getting a failure in response. 使用“ ping hostname”命令从命令提示符执行ping操作时,响应失败。

Is there any way to connect to this host from java program? 有什么方法可以从Java程序连接到该主机吗?

com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception: 

** BEGIN NESTED EXCEPTION ** 

java.net.UnknownHostException
MESSAGE: db726853948.db.1and1.com

STACKTRACE:

java.net.UnknownHostException: db726853948.db.1and1.com
    at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
    at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:907)
    at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1302)
    at java.net.InetAddress.getAllByName0(InetAddress.java:1255)
    at java.net.InetAddress.getAllByName(InetAddress.java:1171)
    at java.net.InetAddress.getAllByName(InetAddress.java:1105)
    at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:246)
    at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:271)
    at com.mysql.jdbc.Connection.createNewIO(Connection.java:2771)
    at com.mysql.jdbc.Connection.<init>(Connection.java:1555)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)
    at java.sql.DriverManager.getConnection(DriverManager.java:664)
    at java.sql.DriverManager.getConnection(DriverManager.java:247)
    at Contct.insertDetails(Contct.java:11)
    at Contct.main(Contct.java:28)

** END NESTED EXCEPTION **
Last packet sent to the server was 0 ms ago.

try adding your hostname to your host file 尝试将主机名添加到主机文件

for example: 例如:

your_host_ip(122.2.2.1)     hostname(db726853948.db.1and1.com)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 连接到有效IP端口时抛出UnknownHostException - UnknownHostException is thrown while connecting to a valid ip port 从 Java 代码连接到 Azure Cosmos DB 时出现 UnknownHostException - UnknownHostException while connecting to Azure Cosmos DB from Java code 连接到 RDS 通过 VPC 对等时 Spring Boot UnknownHostException - Spring Boot UnknownHostException while connecting to RDS throgh VPC peering 连接到数据库时发生异常 - Exception while connecting to the database 连接到服务器上的数据库 - Connecting to database on server 连接到Android中的数据库服务器 - Connecting to a database server in Android 错误:使用 Java =&gt; java.net.UnknownHostException 连接 Google Cloud Storage 时:oauth2.googleapis.com - Error: while connecting Google Cloud Storage using Java => java.net.UnknownHostException: oauth2.googleapis.com 服务器Java的UnknownHostException - UnknownHostException for server java udp客户端/服务器中的unknownhostexception - unknownhostexception in udp client/server 连接到数据库mysql工作台时发生错误:java.sql.SQLNonTransientConnectionException:无法创建与数据库服务器的连接 - Error occur while connecting to database mysql workbench:java.sql.SQLNonTransientConnectionException: Could not create connection to database server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM