我正在尝试在opensuse上使用h2数据库,但我无法使其工作。 我从官方网站上下载了独立于平台的软件包,然后尝试了几个方法来运行它,但没有成功:
所有三个都返回相同的错误:
org.h2.jdbc.JdbcSQLException: IO Exception: "java.net.UnknownHostException: linux-t89a.site: linux-t89a.site" [90028-170]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
at org.h2.message.DbException.get(DbException.java:158)
at org.h2.message.DbException.convert(DbException.java:273)
at org.h2.util.NetUtils.getLocalAddress(NetUtils.java:263)
at org.h2.server.web.WebServer.updateURL(WebServer.java:325)
at org.h2.server.web.WebServer.init(WebServer.java:315)
at org.h2.tools.Server.<init>(Server.java:51)
at org.h2.tools.Server.createWebServer(Server.java:412)
at org.h2.tools.Console.runTool(Console.java:228)
at org.h2.tools.Console.main(Console.java:100)
Caused by: java.net.UnknownHostException: linux-t89a.site: linux-t89a.site
at java.net.InetAddress.getLocalHost(InetAddress.java:1454)
at org.h2.util.NetUtils.getLocalAddress(NetUtils.java:261)
... 6 more
Exception in thread "main" org.h2.message.DbException: IO Exception: "java.net.UnknownHostException: linux-t89a.site: linux-t89a.site" [90028-170]
at org.h2.message.DbException.get(DbException.java:158)
at org.h2.message.DbException.convert(DbException.java:273)
at org.h2.util.NetUtils.getLocalAddress(NetUtils.java:263)
at org.h2.server.TcpServer.getURL(TcpServer.java:193)
at org.h2.tools.Server.getStatus(Server.java:391)
at org.h2.tools.Console.printProblem(Console.java:300)
at org.h2.tools.Console.runTool(Console.java:270)
at org.h2.tools.Console.main(Console.java:100)
Caused by: org.h2.jdbc.JdbcSQLException: IO Exception: "java.net.UnknownHostException: linux-t89a.site: linux-t89a.site" [90028-170]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
... 8 more
Caused by: java.net.UnknownHostException: linux-t89a.site: linux-t89a.site
at java.net.InetAddress.getLocalHost(InetAddress.java:1454)
at org.h2.util.NetUtils.getLocalAddress(NetUtils.java:261)
... 5 more
这是我的java -version:
java version "1.7.0_21"
OpenJDK Runtime Environment (IcedTea 2.3.9) (suse-3.37.1-x86_64)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
我的javac -version:
javac 1.7.0_21
更多信息: 我让一个朋友尝试使用java -jar h2 * .jar过程在UnbuntuX上运行它,并且它有效(我们有相同的java版本,省略了linux发行版)。 我让另一位朋友尝试在他的电脑上使用Opensuse运行它,它没有用,和我的一样错误。
由于
编辑: 根据需要,etc / hosts文件的内容:
#
# hosts This file describes a number of hostname-to-address
# mappings for the TCP/IP subsystem. It is mostly
# used at boot time, when no name servers are running.
# On small systems, this file can be used instead of a
# "named" name server.
# Syntax:
#
# IP-Address Full-Qualified-Hostname Short-Hostname
#
127.0.0.1 localhost
# special IPv6 addresses
::1 localhost ipv6-localhost ipv6-loopback
fe00::0 ipv6-localnet
ff00::0 ipv6-mcastprefix
ff02::1 ipv6-allnodes
ff02::2 ipv6-allrouters
ff02::3 ipv6-allhosts
答案 0 :(得分:2)
我认为问题在于方法InetAddress.getLocalHost()
由于某种原因在您的环境中无效。 H2数据库使用此方法。
答案 1 :(得分:0)
我也遇到了这个问题,我的情况是这样的:
可以通过调用InetAddress.getByName(“127.0.0.1”)来缓解这种情况。我查看了此方法的JDK源代码,看起来因为地址是IP地址,所以它会跳过DNS查找/ loopbackAddress代码流。