如何使用H2 数据库的集成管理前端?
用于创建表、更改表、添加列等操作。
我喜欢SQuirreL SQL Client,而NetBeans非常好用;但更多时候,我只是启动内置org.h2.tools.Server
并浏览端口 8082:
$ java -cp /opt/h2/bin/h2.jar org.h2.tools.Server -help 启动 H2 控制台 (web-) 服务器、TCP 和 PG 服务器。 用法:java org.h2.tools.Server 不带选项运行时,会启动 -tcp、-web、-browser 和 -pg。 选项区分大小写。支持的选项有: [-help] 或 [-?] 打印选项列表 [-web] 使用 H2 控制台启动 Web 服务器 [-webAllowOthers] 允许其他计算机连接 - 见下文 [-webPort ] 端口(默认:8082) [-webSSL] 使用加密 (HTTPS) 连接 [-browser] 启动浏览器并打开一个页面以连接到 Web 服务器 [-tcp] 启动 TCP 服务器 [-tcpAllowOthers] 允许其他计算机连接 - 见下文 [-tcpPort ] 端口(默认:9092) [-tcpSSL] 使用加密 (SSL) 连接 [-tcpPassword ] 关闭 TCP 服务器的密码 [-tcpShutdown ""] 停止 TCP 服务器;示例:tcp://localhost:9094 [-tcpShutdownForce] 不要等到所有连接都关闭 [-pg] 启动 PG 服务器 [-pgAllowOthers] 允许其他计算机连接 - 见下文 [-pgPort ] 端口(默认值:5435) [-baseDir ] H2 数据库的基本目录;对于所有服务器 [-ifExists] 只能打开现有数据库;对于所有服务器 [-trace] 打印额外的跟踪信息;对于所有服务器
H2 控制台应用程序怎么样?
我使用sql-workbench来处理 H2 和我必须处理的任何其他 DBMS,它让我微笑 :-)
我想建议DBEAVER 。它基于 eclipse 并支持更好的数据处理
内置的 shell 客户端也很方便。
java -cp h2*.jar org.h2.tools.Shell
http://opensource-soa.blogspot.com.au/2009/03/how-to-use-h2-shell.html
$ java -cp h2.jar org.h2.tools.Shell -help
Interactive command line tool to access a database using JDBC.
Usage: java org.h2.tools.Shell <options>
Options are case sensitive. Supported options are:
[-help] or [-?] Print the list of options
[-url "<url>"] The database URL (jdbc:h2:...)
[-user <user>] The user name
[-password <pwd>] The password
[-driver <class>] The JDBC driver class to use (not required in most cases)
[-sql "<statements>"] Execute the SQL statements and exit
[-properties "<dir>"] Load the server properties from this directory
If special characters don't work as expected, you may need to use
-Dfile.encoding=UTF-8 (Mac OS X) or CP850 (Windows).
See also http://h2database.com/javadoc/org/h2/tools/Shell.html
一个讨论在这里找到
引用 Thomas Mueller:
http ://www.dbsolo.com/
http://www.minq.se/products/dbvis/
http://executequery.org/index.jsp
http://sqldeveloper.solyp.com/ index.html
http://sql-workbench.net/index.html
http://www.squirrelsql.org/
我建议使用 Jetbrain 的 IDE:DataGrip https://www.jetbrains.com/datagrip/
如果您在 spring 中将其作为嵌入式数据库运行,我使用以下配置在主应用程序运行时启用内置 Web 客户端:
<!-- Run H2 web server within application that will access the same in-memory database -->
<bean id="h2Server" class="org.h2.tools.Server" factory-method="createTcpServer" init-method="start" destroy-method="stop" depends-on="h2WebServer">
<constructor-arg value="-tcp,-tcpAllowOthers,-tcpPort,9092"/>
</bean>
<bean id="h2WebServer" class="org.h2.tools.Server" factory-method="createWebServer" init-method="start" destroy-method="stop">
<constructor-arg value="-web,-webAllowOthers,-webPort,8082"/>
</bean>