Add max query timeout setting for h2 dialect

Change-Id: I78985722fc01f72885318d128a05d617087d8eea
This commit is contained in:
David Ostrovsky
2020-06-29 07:17:26 +02:00
parent 430163a0fd
commit d7cfdbc914
2 changed files with 11 additions and 0 deletions

View File

@@ -1905,6 +1905,13 @@ utils (e.g. MigrateToNoteDb).
+
Default is `false`.
[[database.h2.maxQueryTimeout]]database.h2.maxQueryTimeout::
+
The maximum timeout of a query in milliseconds.
(see http://www.h2database.com/javadoc/org/h2/engine/DbSettings.html?#MAX_QUERY_TIMEOUT[MAX_QUERY_TIMEOUT]).
+
The default is 0, meaning no limit.
[[download]]
=== Section download

View File

@@ -47,6 +47,7 @@ class H2 extends BaseDataSourceType {
public static String appendUrlOptions(Config cfg, String url) {
long h2CacheSize = cfg.getLong("database", "h2", "cacheSize", -1);
long h2MaxQueryTimeout = cfg.getLong("database", "h2", "maxQueryTimeout", -1);
boolean h2AutoServer = cfg.getBoolean("database", "h2", "autoServer", false);
StringBuilder urlBuilder = new StringBuilder().append(url);
@@ -55,6 +56,9 @@ class H2 extends BaseDataSourceType {
// H2 CACHE_SIZE is always given in KB
urlBuilder.append(";CACHE_SIZE=").append(h2CacheSize / 1024);
}
if (h2MaxQueryTimeout >= 0) {
urlBuilder.append(";MAX_QUERY_TIMEOUT=").append(h2MaxQueryTimeout);
}
if (h2AutoServer) {
urlBuilder.append(";AUTO_SERVER=TRUE");
}