H2 数据库无法在 Opensuse 12.2 上运行

问题描述 投票:0回答:3

我正在尝试在 opensuse 上使用 h2 数据库,但无法使其工作。 我从官方网站下载了与平台无关的包,然后尝试了几种方法来运行它,但没有成功:

  • 使 /h2/bin/h2.sh 可执行,然后执行控制台命令 ./h2.sh
  • 使用命令 java -jar h2*.jar
  • 使用 Play!Framework 命令 h2-browser

所有三个都返回相同的错误:

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版本:

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版本:

javac 1.7.0_21

更多信息: 我让一个朋友尝试在 UnbuntuX 上运行它,使用 java -jar h2*.jar 程序,它成功了(我们有相同的 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
h2 opensuse
3个回答
4
投票

我认为问题在于方法

InetAddress.getLocalHost()
由于某种原因在您的环境中不起作用。 H2数据库就是采用这种方法。

这个问题和可能的答案在问题InetAddress.getLocalHost() throws UnknownHostException

中进行了描述

0
投票

我也遇到这个问题了,我的情况是这样的:

  1. 将机器连接到 VPN。此过程为我的机器分配一个唯一的主机名。每次我连接到 VPN 时,此主机名都会更改。
  2. 关闭与 VPN 的连接。
  3. 以tcp模式启动H2。

通过调用 InetAddress.getByName("127.0.0.1") 可能会缓解这种情况。我查看了此方法的 JDK 源代码,发现由于地址是 IP 地址,因此它跳过了 DNS 查找/loopbackAddress 代码流程。


0
投票

我的案例的解决方案很简单。我正在使用 openSUSE TW,我最终所做的是将我的

hostname
添加到
/etc/hosts
,对于 IPv4 和 IPv6。

  1. 在终端中输入“主机名”以查找您的
    hostname
  2. 编辑
    /etc/hosts

我的主机名是:“source”,所以这就是我更新我的

/etc/hosts
文件的方式。

sudo vim /etc/hosts

# IPv4 addresses
127.0.0.1       localhost source

# IPv6 addresses
::1             localhost source

H2 数据库控制台现在应该在浏览器中打开,无需重新启动。

注意:我通过阅读OP共享的InetAddress.getLocalHost() throws UnknownHostException中“Marius Soutier”的评论找到了答案。我想我会在这里扩展它以帮助其他人。

© www.soinside.com 2019 - 2024. All rights reserved.