H2のJDBC接続文字江列のサンプル(本家HPより拝借)
PureJavaの組み込みDBはたくさんあるけども、一番使いやすいのはH2ですかね。
いろいろ接続方法がありますが、暗号化とかも選べてお得な感じです。
個人的にはクラスパス表記(jdbc:h2:classpath:/data/sampleとか)をサポートして欲しいなと思いました。
接続方法 | 表記 |
---|---|
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: |
jdbc:h2:mem:test_mem | |
Remote using TCP/IP | jdbc:h2:tcp:// |
jdbc:h2:tcp://localhost/test | |
jdbc:h2:tcp://dbserv:8084/sample | |
Remote 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:quickAndDirty;FILE_LOCK=NO | |
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: |
User Name and/or Password | jdbc:h2: |
jdbc:h2:file:sample;USER=sa;PASSWORD=123 | |
Log Index Changes | jdbc:h2: |
jdbc:h2:file:sample;LOG=2 | |
Debug Trace Settings | jdbc:h2: |
jdbc:h2:file:sample;TRACE_LEVEL_FILE=3 | |
Ignore Unknown Settings | jdbc:h2: |
Changing Other Settings | jdbc:h2: |
jdbc:h2:file:sample;TRACE_LEVEL_SYSTEM_OUT=3 |