Sunday, March 25, 2018

h2 remote

./h2.sh -tcpAllowOthers -webAllowOthers


Web Console server running at http://localhost:8082 (others can connect)
Failed to start a browser to open the URL http://localhost:8082: Browser detection failed and system property h2.browser not set
TCP server running at tcp://localhost:9092 (others can connect)
PG server running at pg://localhost:5435 (only local connections)


At this point you can connect remotely to the console (even if it says "localhost") and you can specify a remote tcp url in your datasource:

jdbc:h2:tcp://YOURIP:9092/~/YOURDB;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE

When using h2, don't forget to use

<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>

in your persistence.xml
(see http://www.mastertheboss.com/jboss-server/jboss-datasource/h2-database-tutorial )


No comments: