2、启动
cd H2\bin h2.bat/.sh 启动
3、如需启动远程访问
h2.bat -webAllowOthers -webPort 8012 -tcpAllowOthers -tcpPort 8013 【端口自选】
4、异常处理
(1)、版本不同---解决方法 更换相同版本 1.3版本下载 1.4版本下载
07-18 16:39:32 jdbc: exception
org.h2.jdbc.JdbcSQLException: Connection is broken: "unexpected status 16842752" [90067-173]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:331)
at org.h2.message.DbException.get(DbException.java:171)
at org.h2.message.DbException.get(DbException.java:148)
at org.h2.engine.SessionRemote.done(SessionRemote.java:594)
at org.h2.command.CommandRemote.prepare(CommandRemote.java:65)
at org.h2.command.CommandRemote.(CommandRemote.java:45)
at org.h2.engine.SessionRemote.prepareCommand(SessionRemote.java:449)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1142)
at org.h2.jdbc.JdbcConnection.getTransactionIsolation(JdbcConnection.java:756)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
5、连接注意点
数据库支持多种连接模式和连接设置,不同的连接模式和连接设置是通过不同的URL来区分的,URL中的设置是不区分大小写。
~ 表示本地user目录, 在链接中也可使用相对(相对于命令文件所在目录)或绝对目录进行连接
Topic
URL Format and Examples
jdbc:h2:[file:][]
jdbc:h2:~/test
jdbc:h2:file:/data/sample
jdbc:h2:file:C:/data/sample (Windows only)
jdbc:h2:mem:
jdbc:h2:mem:
jdbc:h2:mem:test_mem
jdbc:h2:tcp://[:]/[]
jdbc:h2:tcp://localhost/~/test
jdbc:h2:tcp://dbserv:8084/~/sample
jdbc:h2:ssl://[:]/
jdbc:h2:ssl://secureserv:8085/~/sample;
jdbc:h2:;CIPHER=[AES|XTEA]
jdbc:h2:ssl://secureserv/~/testdb;CIPHER=AES
jdbc:h2:file:~/secure;CIPHER=XTEA
jdbc:h2:;FILE_LOCK={NO|FILE|SOCKET}
jdbc:h2:file:~/quickAndDirty;FILE_LOCK=NO
jdbc:h2:file:~/private;CIPHER=XTEA;FILE_LOCK=SOCKET
jdbc:h2:;IFEXISTS=TRUE
jdbc:h2:file:~/sample;IFEXISTS=TRUE
jdbc:h2:;DB_CLOSE_ON_EXIT=FALSE
jdbc:h2:[;USER=][;PASSWORD=]
jdbc:h2:file:~/sample;USER=sa;PASSWORD=123
jdbc:h2:;LOG=2
jdbc:h2:file:~/sample;LOG=2
jdbc:h2:;TRACE_LEVEL_FILE=
jdbc:h2:file:~/sample;TRACE_LEVEL_FILE=3
jdbc:h2:;IGNORE_UNKNOWN_SETTINGS=TRUE
jdbc:h2:;ACCESS_MODE_LOG=rws;ACCESS_MODE_DATA=rws
在Zip文件中的数据库
jdbc:h2:zip:!/
jdbc:h2:zip:~/db.zip!/test
jdbc:h2:;MODE=
jdbc:h2:~/test;MODE=MYSQL
jdbc:h2:;AUTO_RECONNECT=TRUE
jdbc:h2:tcp://localhost/~/test;AUTO_RECONNECT=TRUE
jdbc:h2:;AUTO_SERVER=TRUE
jdbc:h2:~/test;AUTO_SERVER=TRUE
jdbc:h2:;=[;=...]
jdbc:h2:file:~/sample;TRACE_LEVEL_SYSTEM_OUT=3