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:][
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:
Server mode (remote connections) using
TCP/IP
jdbc:h2:tcp://
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://
jdbc:h2:ssl://secureserv:8085/~/sample;
Using encrypted files
jdbc:h2:
jdbc:h2:ssl://secureserv/~/testdb;CIPHER=AES
jdbc:h2:file:~/secure;CIPHER=XTEA
File locking methods jdbc:h2:
jdbc:h2:file:~/private;CIPHER=XTEA;FILE_LOCK=SOCKET
Only open if it already exists jdbc:h2:
jdbc:h2:file:~/sample;IFEXISTS=TRUE
Don't close the database when the VM
exits jdbc:h2:
Execute SQL on connection
jdbc:h2:
jdbc:h2:file:~/sample;INIT=RUNSCRIPT FROM '~/create.sql'//;RUNSCRIPT FROM
'~/populate.sql'
User name and/or password jdbc:h2:
jdbc:h2:file:~/sample;USER=sa;PASSWORD=123
Debug trace settings jdbc:h2:
jdbc:h2:file:~/sample;TRACE_LEVEL_FILE=3
Ignore unknown settings jdbc:h2:
Custom file access mode jdbc:h2:
Database in a zip file jdbc:h2:zip:
jdbc:h2:zip:~/db.zip!/test
Compatibility mode jdbc:h2:
jdbc:h2:~/test;MODE=MYSQL
Auto-reconnect jdbc:h2:
jdbc:h2:tcp://localhost/~/test;AUTO_RECONNECT=TRUE
Automatic mixed mode jdbc:h2:
jdbc:h2:~/test;AUTO_SERVER=TRUE
Page size jdbc:h2:
Changing other settings jdbc:h2:
jdbc:h2:file:~/sample;TRACE_LEVEL_SYSTEM_OUT=3
详细内容请查看H2 Documentation文档的37页。