0

I am able to connect to my default database. But added to that I also want to connect another database. I am using Play Framework 1.2.6. I know that this support is present in the main branch of Play 1.2.x. Can any one please help me, how I can achieve this in 1.2.6.

Thank you

A Paul
  • 8,113
  • 3
  • 31
  • 61

4 Answers4

1

Play 1.2.6 (or the 1.2.x branch) doesn't support multiple database connections out of the box. This support will be available in Play 1.3 which has not been released yet.

Here is the according ticket from the Play bug tracker:
http://play.lighthouseapp.com/projects/57987-play-framework/tickets/706

mkurz
  • 2,658
  • 1
  • 23
  • 35
0

What database are you using? If your database supports multiple schemas you can achieve what you want by adding the following line on top of class.

@Entity
@Table(name="<table_name>",schema="<schema_2>")
public class xxx extends Model {

Entity and Table are part of the persistence api.

Harish
  • 638
  • 1
  • 10
  • 20
  • Thank you for your reply. I will give it a try and will come back. I am using mysql database. – A Paul Aug 29 '13 at 06:29
  • I have tried this, but seems it did not worked. It did not created the table in the schema_2. I am using JPA with Play framework. Now I have one doubt, Play as a framework needs to be connected to this Database before it can create the table or access data right? Please let me know if I am wrong here. – A Paul Aug 29 '13 at 06:47
  • If you are already connected to the default schema in your mysql database, then connecting to schema_2 shouldn't be a problem as we are explicitly mentioning the second schema name in the model class. Especially with JPA model it should work. But of course, you need to have the schema_2 tables defined as models in your JPA. – Harish Aug 29 '13 at 15:06
  • Yes you are correct. But in my case it is JPA with Play framework. And database connection is done by Play using the config file. Thank you! – A Paul Aug 30 '13 at 10:11
0

Found another interesting solution to your problem. Use below link if you need occasional access to the second database.

click here

Community
  • 1
  • 1
Harish
  • 638
  • 1
  • 10
  • 20
0

You can try to use this module : http://www.playframework.com/modules/multidb

Aj.

Semantyc
  • 11
  • 1