【发布时间】:2019-03-30 17:21:59
【问题描述】:
我对多个数据库(和数据库服务器)有完全相同的数据库定义。如何告诉 Jooq 使用与我创建的“连接”相同的数据库来连接数据库?
示例(用于 MySQL):
- jdbc:mysql://localhost:3306/tsm - 我的开发数据库(tsm),用于生成代码
- jdbc:mysql://RemoteAmazonDBHost:3306/customer1 - 我的一位客户
- jdbc:mysql://RemoteAmazonDBHost:3306/customer2 - 另一个客户
所有 3 个数据库都具有相同的定义、相同的表、索引等。TSM 是我们的应用程序使用的标准。
也许我应该使用DSL.using( Connection, Setting ) 而不是DSL.using(Connection)?这就是手册所暗示的here?
如果我只有一个“输入”模式,我必须指定它吗?换句话说,我可以这样做吗:
Settings settings = new Settings()
.withRenderMapping(new RenderMapping()
.withSchemata(
new MappedSchema().withOutput(
databaseInfo.getProperties().getProperty("database.db"))));
或者我必须这样做:
Settings settings = new Settings()
.withRenderMapping(new RenderMapping()
.withSchemata(
new MappedSchema().withInput("TSM")
.withOutput(databaseInfo.getProperties().getProperty("database.db"))));
【问题讨论】: