1

I am trying to share an in-memory H2 Database I created using SORM framework in my Play Framework application. Below is the code for my database code

object DB extends Instance(entities = Seq(Entity[Person]()), url ="jdbc:h2:mem:db1"){}

The solution stated at H2 Database site is to start a TCP Server. In Java applications I am able to share the database using the following code

org.h2.tools.Server server = org.h2.tools.Server.createTcpServer();
server.start();

Connection conn = DriverManager.getConnection("jdbc:h2:mem:db1");

How can I start a tcp server in my Play application when it starts or when it is running?

Frank Smith
  • 1,717
  • 4
  • 18
  • 32
  • I don't think you should run it as standalone server. play support running h2 out of the box. See [How to use SORM framework with Play Framework?](http://stackoverflow.com/questions/14908054/how-to-use-sorm-framework-with-play-framework) – roterl Oct 07 '14 at 12:16
  • I'm just resorting to this to create a quick prototype. thanks for the info – Frank Smith Oct 07 '14 at 13:08

1 Answers1

2

From playframework documentation, you should be able to place the code in onStart function.

Adi
  • 727
  • 3
  • 10