大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全系列IDE稳定放心使用
- 纯Java编写,不受平台的限制;
- 只有一个jar文件,适合作为嵌入式数据库使用;
- h2提供了一个十分方便的web控制台用于操作和管理数据库内容;
- 功能完整,支持标准SQL和JDBC。麻雀虽小五脏俱全;
- 支持内嵌模式、服务器模式和集群。
进入H2的bin目录。
- 复制h2.sh为h2_server.sh文件;
- 编辑h2_server.sh,如下:#!/bin/shdir=$(dirname“$0“)java -cp “$dir/h2-1.3.176.jar:$H2DRIVERS:$CLASSPATH“ org.h2.tools.Server -tcpAllowOthers -webAllowOthers -webPort 8082“$@“
- 说明:
- 具体的运行方式
- 通过远程浏览器来访问h2
注意:导出时就算加上编码,导出后的文件用VIM、Editplus查看是正常,但用Excel查看也仍然会是乱码的。需要用Editplus另存为Unicode,就好了。
导入数据:
INSERT INTO TEST ( SELECT * FROM CSVREAD(‘d:/test.csv ‘)) ;
导入结构及数据,
根据csv文件创建h2数据表。
dependency
>
<
groupId
>
com.h2database
</
groupId
>
<
artifactId
>
h2
</
artifactId
>
<
version
>
1.4.195
</
version
>
dependency
>
=
org.h2.Driver
=
jdbc:h2:D:/test
=
sa
=
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 TLS | jdbc:h2:ssl://<server>[:<port>]/<databaseName> jdbc:h2:ssl://localhost:8085/~/sample; |
Using encrypted files | jdbc:h2:<url>;CIPHER=AES jdbc:h2:ssl://localhost/~/test;CIPHER=AES jdbc:h2:file:~/secure;CIPHER=AES |
File locking methods | jdbc:h2:<url>;FILE_LOCK={FILE|SOCKET|NO} jdbc:h2:file:~/private;CIPHER=AES;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 |
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/182651.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...