[JAVA] Set console timeout (session timeout) for H2 Database

TL;DR

Console timeout

Starting H2 Database launches a web console accessible at http: // localhost: 8082.

That's about this.

image.png

This session timeout defaults to 30 minutes.

Some people may find it short. There is time to leave it for a while, and when it times out, the query I was writing will disappear.

Set h2.consoleTimeout

To set the web console timeout, it seems that you should set CONSOLE_TIMEOUT.

SysProperties

CONSOLE_TIMEOUT

The default is 1800000, and when you actually specify it as a system property, specify h2.consoleTimeout.

https://github.com/h2database/h2database/blob/version-1.4.200/h2/src/main/org/h2/engine/SysProperties.java#L153-L158

I noticed that the property ʻid of SysProperties` was this key when I was writing the article.

https://www.h2database.com/javadoc/org/h2/engine/SysProperties.html#h2.consoleTimeout

Specify this as a system property when you start H2 Database.

Refer to here for the specification method.

Settings Read from System Properties

I ran it on H2 Database version 1.4.200.

$ java -cp bin/h2-1.4.200.jar -Dh2.consoleTimeout=[The number of seconds] org.h2.tools.Console

The following is an example of explicitly specifying the default value of 30 minutes (1800000 seconds).

$ java -cp bin/h2-1.4.200.jar -Dh2.consoleTimeout=1800000 org.h2.tools.Console

You can now change the console timeout (session timeout).

The Java version used for confirmation is here.

$ java -version
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-8u222-b10-1ubuntu1~18.04.1-b10)
OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)

Recommended Posts

Set console timeout (session timeout) for H2 Database
Read H2 database for unit tests
How to create a database for H2 Database anywhere
Spring Boot --How to set session timeout time