search
LoginSignup
2

More than 5 years have passed since last update.

posted at

updated at

Playframeworkで複数のDBに接続する

カレンダーがなかな充実しないので、小ネタを。。。
今回はメモ的な感覚で。。。

設計上DBを2つに分けてたいと思って、まさかなと思って試したら案の定できたので残しておく

application.conf
db {
# 1つ目のDB設定
  main.driver = org.mariadb.jdbc.Driver
  main.url = "jdbc:mariadb://localhost:3306/MAIN_DB_NAME"
  main.username = USER_NAME
  main.password = PASSWORD

# 2つ目のDB設定
  sub.driver = org.mariadb.jdbc.Driver
  sub.url = "jdbc:mariadb://localhost:3306/SUB_DB_NAME"
  sub.username = USER_NAME
  sub.password = PASSWORD

}
ebean {
  main = ["models.entity.main.*"]
  sub = ["models.entity.sub.*"]
}

考えればわかることでしたね。。。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
2