如何在Play Framework中使用持久H2数据库,而不是在内存中 [英] How to use a persistent H2 database in the Play Framework instead of in-memory
本文介绍了如何在Play Framework中使用持久H2数据库,而不是在内存中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Java Todo List教程中使用的H2数据库如下:
The H2 database used in the Java Todo List tutorial is the following:
db.default.driver=org.h2.Driver
db.default.url="jdbc:h2:mem:play"
如何修改配置文件以使用持久性数据库而不是内存版本。我需要设置一个完全独立的数据库,还是可以修改 db.default.url
属性?
How do I modify the configuration file to use a persistent database as opposed to an in-memory version. Do I need to setup an entirely separate DB or can I modify the db.default.url
property?
我正在使用Play! 2.0.3。
I'm using Play! 2.0.3.
推荐答案
我找到了解决方案。
要创建文件数据库,请修改以下内容:
To create a file database, modify the following:
从
db.default.url="jdbc:h2:mem:play"
到
db.default.url="jdbc:h2:file:data/db"
其中 data / db
into:
data /
数据库文件相对于项目根目录的文件夹位置。
data/
The folder location of the database files relative to your project root.
db
数据库文件的名称。
db
The name of your database files.
这篇关于如何在Play Framework中使用持久H2数据库,而不是在内存中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文