开发者

connect to different type of DBs

Is it possible for a playframework app to connect to different types of database systems, for example, MySQL and also MongoDB, and decide on开发者_C百科 the fly based on the traffic which database:table on which database system to talk to.


Basically, Play manages only one RDBMS database using the DB configuration in application.conf. Play takes care of providing a Connection object to modules requiring it (the default JPA and also Siena for ex)

But nothing prevents from connecting several databases at the same time to Play.

Then querying the right database depending on some routing rules is not really meaningful because it's more at the class model level that it is decided right now. If your model is JPA, it will use the RDBMS, if it is Siena, it will use GAE/RDBMS/SDB (siena doesn't manage yet multidb connection), if it is Morphia, it will use MongoDB etc...

Thus, if you want to use directly SQL (or anything else) for ex & multidb connections and route to the right DB/table according to some rules, nothing prevents from doing it. Nevertheless, you will have to implement a little Play module to manage it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜