0

My Play app uses H2 in-memory database when it runs in dev or test mode. I want to access this database when the app runs in dev mode. So I have the following options

1) Run the database in Embedded/Mixed mode. And make the play framework expose the database to other processes.

2) Run in H2 database in server mode (least preferred). But in this the framework should start the database server deamon process (not manually).

My current application.conf file looks like this.

db.default.driver=org.h2.Driver
db.default.url="jdbc:h2:mem:dev;MODE=MYSQL;DB_CLOSE_DELAY=-1;"
db.default.jndiName=dev
rogue-one
  • 11,259
  • 7
  • 53
  • 75
  • Check this old answer if it can help you: http://stackoverflow.com/a/15992638/1066240 – biesior Feb 25 '15 at 15:06
  • my initial test for method 1 didn't succeed. the database is empty and no tables mentioned in the evolution script is executed. But the tables are available in the app. I will try again this. – rogue-one Feb 25 '15 at 15:24
  • @biesior Thanks, after updating the jdbc url I was able to connect to the database. BTW play runs H2 in embedded mode or mixed mode? – rogue-one Feb 25 '15 at 15:39

1 Answers1

1

From your terminal use activator cmd to run Play's console, within it run h2-browser cmd to open console in the browser and finally run your app (withinh the same Play console) with ie run cmd.

Make sure that you are using the same credentials (especially JDBC URL) in both places.

AFAIK it uses embedded mode (therefore it's required to start both within one process)

(origin)

Community
  • 1
  • 1
biesior
  • 55,576
  • 10
  • 125
  • 182