DavidLei08 / BlogSqlite

Apache License 2.0
7 stars 12 forks source link

怎么切换数据源? #1

Open zhangjing007 opened 3 years ago

zhangjing007 commented 3 years ago

请问您这个怎么切换数据源啊?

DavidLei08 commented 3 years ago

setDataSourceKey(String 这个方法可以切换数据源

DavidLei08 commented 3 years ago

//测试动态数据源 @Test void checkoutDb(){ //构建数据源 DataSource dataSource = SqliteBuilder.create().url("jdbc:sqlite:E:/git_space/BlogSqlite/sqlite/pro.db").build(); //添加数据 DynamicDataSource.addDataSource("db2",dataSource); //切换数据源 DynamicDataSource.checkoutDataSource("db02"); }