Friday, April 20, 2018

h2 remote TCP client

telnet ip port

Remote connections to this server are not allowed, see -tcpAllowOthers
org.h2.jdbc.JdbcSQLException: Remote connections to this server are not allowed, see -tcpAllowOthers [90117-197]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:357)
at org.h2.message.DbException.get(DbException.java:179)
at org.h2.message.DbException.get(DbException.java:155)
at org.h2.message.DbException.get(DbException.java:144)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:89)
at java.lang.Thread.run(Thread.java:748)
Connection closed by foreign host.


You fix the issue by running h2 server as:

java -cp "/opt/h2/bin/h2-1.4.197.jar:$H2DRIVERS:$CLASSPATH" -Dh2.consoleTimeout=500000 org.h2.tools.Console -web -webAllowOthers -tcp -tcpAllowOthers


on the client side, in wildfly, you have

<datasource jndi-name="java:jboss/datasources/DOICHDS" pool-name="DOICHDS" enabled="true" use-java-context="true">
<connection-url>jdbc:h2:tcp://yourserverip:9092/~/PIPPO;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
<driver>h2</driver>
<security>
<user-name>PIPPO</user-name>
<password>PIPPO</password>
</security>
</datasource>

See https://stackoverflow.com/a/9838282/651288



No comments: