2014-09-10 82 views

回答

1

你會爲第二個數據庫的另一個名字(而非default)中application.conf與它自己的設置:

db.default.driver=com.mysql.jdbc.Driver 
db.default.url= ... 
db.default.user= ... 
db.default.password= ... 

db.anotherdb.driver=com.mysql.jdbc.Driver 
db.anotherdb.url= ... 
db.anotherdb.user= ... 
db.anotherdb.password= ... 

然後,你可以指定要使用像這樣的數據庫:

DB.withConnnection("default") { implicit connection => 
    // uses the database named "default" 
} 

DB.withConnnection("anotherdb") { implicit connection => 
    // uses the database named "anotherdb" 
}