Scala Play Slick Connection多个架构

时间:2016-04-25 07:37:45

标签: scala playframework-2.0 slick

这是我的代码 Application.conf

slick.dbs.default.driver="com.typesafe.slick.driver.oracle.OracleDriver$"
slick.dbs.default.db.driver=oracle.jdbc.driver.OracleDriver
slick.dbs.default.db.url="jdbc:oracle:thin:@XXXXXXX"
slick.dbs.default.db.user=param
slick.dbs.default.db.password="xxxx"

slick.dbs.default.driver="com.typesafe.slick.driver.oracle.OracleDriver$"
slick.dbs.default.db.driver=oracle.jdbc.driver.OracleDriver
slick.dbs.default.db.url="jdbc:oracle:thin:@XXXXXXX"
slick.dbs.default.db.user=param2
slick.dbs.default.db.password="xxxx"

如何连接多个架构scala播放slick oracle ????

1 个答案:

答案 0 :(得分:3)

With slick.dbs.default.*, you configurate your default schema. If you want to have multiple database connections, you can declare named databases.

Try to use something like this in your configuration:

oracle2.driver="com.typesafe.slick.driver.oracle.OracleDriver$"
oracle2.db.driver=oracle.jdbc.driver.OracleDriver
oracle2.db.url="jdbc:oracle:thin:@XXXXXXX"
oracle2.db.user=param2
oracle2.db.password="xxxx"

By default, the default database connection is used. If you'd like to use your other databases, in this case oracle2, you can inject them using the NamedDatabase annotation.

@NamedDatabase("oracle2") override protected val dbConfigProvider: DatabaseConfigProvider