how to create new database in H2?

社会主义新天地 提交于 2019-12-04 05:38:09

From http://www.h2database.com/html/tutorial.html#creating_new_databases,

By default, if the database specified in the URL does not yet exist, a new (empty) database is created automatically. The user that created the database automatically becomes the administrator of this database.

The settings of the H2 Console are stored in a configuration file called .h2.server.properties in your user home directory. For Windows installations, the user home directory is usually C:\Documents and Settings\[username] or C:\Users\[username]. The configuration file contains the settings of the application and picked up when the H2 Console is started.

Below config to create a new database on startup:

  1. add newline in property file.

0=Generic H2 (Server)|org.h2.Driver|jdbc\:h2\:tcp\://localhost/~/db_name|sa

  1. open the command prompt go to the \bin directory where h2 has installed:

e.g. cd C:\Program Files (x86)\H2\bin

  1. and run following the command java -cp h2-1.4.194.jar org.h2.tools.Server.

Other General Settings:

webAllowOthers: allow other computers to connect.

webPort: the port of the H2 Console

webSSL: use encrypted TLS (HTTPS) connections.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!