H2各种URL

This database supports multiple connection modes and connection settings. This is achieved using different database URLs.Settings in the URLs are not case sensitive.

 

 

Topic                       URL Format and Examples
Embedded (local) connection
jdbc:h2:[file:][<path>]<databaseName>
jdbc:h2:~/test
jdbc:h2:file:/data/sample
jdbc:h2:file:C:/data/sample (Windows only)


In-memory (private) jdbc:h2:mem:


In-memory (named) jdbc:h2:mem:<databaseName>     jdbc:h2:mem:test_mem


Server mode (remote connections) using
TCP/IP
jdbc:h2:tcp://<server>[:<port>]/[<path>]<databaseName>
jdbc:h2:tcp://localhost/~/test
jdbc:h2:tcp://dbserv:8084/~/sample jdbc:h2:tcp://localhost/mem:test


Server mode (remote connections) using
SSL/TLS
jdbc:h2:ssl://<server>[:<port>]/<databaseName>
jdbc:h2:ssl://secureserv:8085/~/sample;


Using encrypted files
jdbc:h2:<url>;CIPHER=[AES|XTEA]
jdbc:h2:ssl://secureserv/~/testdb;CIPHER=AES
jdbc:h2:file:~/secure;CIPHER=XTEA


File locking methods jdbc:h2:<url>;FILE_LOCK={FILE|SOCKET|NO}
jdbc:h2:file:~/private;CIPHER=XTEA;FILE_LOCK=SOCKET


Only open if it already exists jdbc:h2:<url>;IFEXISTS=TRUE
jdbc:h2:file:~/sample;IFEXISTS=TRUE


Don't close the database when the VM
exits
jdbc:h2:<url>;DB_CLOSE_ON_EXIT=FALSE


Execute SQL on connection
jdbc:h2:<url>;INIT=RUNSCRIPT FROM '~/create.sql'
jdbc:h2:file:~/sample;INIT=RUNSCRIPT FROM '~/create.sql'//;RUNSCRIPT FROM
'~/populate.sql'


User name and/or password jdbc:h2:<url>[;USER=<username>][;PASSWORD=<value>]
jdbc:h2:file:~/sample;USER=sa;PASSWORD=123


Debug trace settings jdbc:h2:<url>;TRACE_LEVEL_FILE=<level 0..3>
jdbc:h2:file:~/sample;TRACE_LEVEL_FILE=3


Ignore unknown settings jdbc:h2:<url>;IGNORE_UNKNOWN_SETTINGS=TRUE


Custom file access mode jdbc:h2:<url>;ACCESS_MODE_DATA=rws


Database in a zip file jdbc:h2:zip:<zipFileName>!/<databaseName>
jdbc:h2:zip:~/db.zip!/test


Compatibility mode jdbc:h2:<url>;MODE=<databaseType>
jdbc:h2:~/test;MODE=MYSQL


Auto-reconnect jdbc:h2:<url>;AUTO_RECONNECT=TRUE
jdbc:h2:tcp://localhost/~/test;AUTO_RECONNECT=TRUE


Automatic mixed mode jdbc:h2:<url>;AUTO_SERVER=TRUE
jdbc:h2:~/test;AUTO_SERVER=TRUE


Page size jdbc:h2:<url>;PAGE_SIZE=512


Changing other settings jdbc:h2:<url>;<setting>=<value>[;<setting>=<value>...]
jdbc:h2:file:~/sample;TRACE_LEVEL_SYSTEM_OUT=3

详细内容请查看H2 Documentation文档的37页。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值