注意:1.此控制台和接口只能暴露给开发人员使用;2.为了数据安全只做了查询功能。
控制台:http://ip:8088
离线接口文档:http://ip:8088/offlineDoc
在线接口文档 :http://ip:8088/onlineDoc或者https://console-docs.apipost.cn/preview/17de6bd4ab90cd51/6a78ffcb10822da4
- 将sqlite文件夹添加到jar包同级路径
- 运行:
nohub java -jar 【你的jar包】 &
spring:
thymeleaf:
cache: false
mode: HTML5
datasource:
dynamic:
#primary-默认数据源
primary: master
p6spy: true
#strict false 允许空数据源启动
strict: false
datasource:
#sqLite不要乱动,默认存储sql语句信息
sqLite:
driver-class-name: org.sqlite.JDBC
url: jdbc:sqlite::resource:sqlite/querySql.db
username:
password:
master:
url: jdbc:db2://124.223.62.162:50000/testdb
username: db2inst1
password: password
driver-class-name: com.ibm.db2.jcc.DB2Driver
//通用数据源会根据maven中配置的连接池根据顺序依次选择。
//默认的顺序为druid>hikaricp>beecp>dbcp>spring basic
@PostMapping("/add")
public Set<String> add(@Validated @RequestBody DataSourceDTO dto) {
DataSourceProperty dataSourceProperty = new DataSourceProperty();
BeanUtils.copyProperties(dto, dataSourceProperty);
DynamicRoutingDataSource ds = (DynamicRoutingDataSource) dataSource;
DataSource dataSource = dataSourceCreator.createDataSource(dataSourceProperty);
ds.addDataSource(dto.getPoolName(), dataSource);
return ds.getDataSources().keySet();
}
两行代码
DynamicRoutingDataSource ds = (DynamicRoutingDataSource) dataSource;
ds.removeDataSource(name);
DynamicRoutingDataSource ds = (DynamicRoutingDataSource) dataSource;
return ds.getDataSources().keySet();
create table SQLMAP
(
name text not null /* sql语句别名 */
constraint SQLMAP_pk
primary key,
poolName text not null, /* 连接池名 */
sqlText text not null, /* sql语句 */
args text /* 相关参数 暂时用不上*/
);
接口:/sqlite/add POST
接口 :/sqlite/getList/ POST
接口 /sqlite/remove/ DELETE
https://console-docs.apipost.cn/preview/17de6bd4ab90cd51/6a78ffcb10822da4