h2官网 http://www.h2database.com/html/advanced.html
h2是支持jdbc协议的
h2应该广泛,可以作为本地缓存,客户端缓存,单元测试的数据库
使用h2db作为数据库,去做单元测试,
据说他的sql和sqlserver类似,但是目前使用sql语法未发现问题。
遇到一点问题,关于h2的ddl的定义,最简单的方式就是下载代码 http://www.h2database.com/html/download.html
然后各种测试了啊。
spring.h2.console.path: /tmp/h2-console
spring.h2.console.enabled: true
spring.datasource.schema: classpath:sql/data_meta.sql
#spring.datasource.data: classpath:sql/data.sql
#数据库
spring.shardingsphere.datasource.names=master,slave1
spring.shardingsphere.datasource.master.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.master.driver-class-name=org.h2.Driver
spring.shardingsphere.datasource.master.jdbc-url=jdbc:h2:mem:data_meta;MODE=MySQL;
spring.shardingsphere.datasource.master.username=root
spring.shardingsphere.datasource.master.password=root
spring.shardingsphere.datasource.master.pool-name=HikariPool-1
spring.shardingsphere.datasource.master.minimum-idle=1
spring.shardingsphere.datasource.master.maximum-pool-size=5
spring.shardingsphere.datasource.master.idle-timeout=600000
spring.shardingsphere.datasource.master.max-lifetime=1200000
spring.shardingsphere.datasource.master.connection-timeout=30000
spring.shardingsphere.datasource.master.connection-test-query=SELECT 1
spring.shardingsphere.datasource.slave1.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.slave1.driver-class-name=org.h2.Driver
spring.shardingsphere.datasource.slave1.jdbc-url=jdbc:h2:mem:data_meta;MODE=MySQL;
spring.shardingsphere.datasource.slave1.username=root
spring.shardingsphere.datasource.slave1.password=root
spring.shardingsphere.datasource.slave1.pool-name=HikariPool-2
spring.shardingsphere.datasource.slave1.minimum-idle=1
spring.shardingsphere.datasource.slave1.maximum-pool-size=5
spring.shardingsphere.datasource.slave1.idle-timeout=600000
spring.shardingsphere.datasource.slave1.max-lifetime=1200000
spring.shardingsphere.datasource.slave1.connection-timeout=30000
spring.shardingsphere.datasource.slave1.connection-test-query=SELECT 1
spring.shardingsphere.masterslave.load-balance-algorithm-type=round_robin
spring.shardingsphere.sharding.master-slave-rules.master.master-data-source-name=master
spring.shardingsphere.sharding.master-slave-rules.master.slave-data-source-names=slave1
meta文件
CREATE TABLE if not exists `ad_id` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id',
`customer_id` bigint(10) NOT NULL DEFAULT '0' COMMENT '用户id',
`created_at` timestamp NOT NULL DEFAULT '1970-01-01 08:00:01' COMMENT '创建时间',
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`)
);