Saturday, June 28, 2014

Grails: How to provide tcp connection from outside to an embedded H2 database?

Step 1) Create web.xml configuration by executing:
grails create-web-xml-config
Step 2) Make this change in WebXmlConfig.groovy
listener.add = true
Step 3) Add a listener in WebXmlConfig.groovy:
listener.classNames = ["org.h2.server.web.DbStarter"]
Step 4) Add following line in WebXmlConfig.groovy:
contextparams = ["db.tcpServer": '-tcpAllowOthers']

Restart grails app now. H2 db should be accessible at port 9092.