From f8de5a59328666151ca3a98bce34094409eabd87 Mon Sep 17 00:00:00 2001 From: hrj Date: Mon, 12 Apr 2021 17:01:24 +0530 Subject: [PATCH] minor: added comment about per thread connections --- src/main/scala/lc/database/statements.scala | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/scala/lc/database/statements.scala b/src/main/scala/lc/database/statements.scala index ec0ae24..d23d6e2 100644 --- a/src/main/scala/lc/database/statements.scala +++ b/src/main/scala/lc/database/statements.scala @@ -110,6 +110,13 @@ class Statements(dbConn: DBConn, maxAttempts: Int) { } object Statements { + /* Note: h2 documentation recommends using a separate DB connection per thread + But in practice, as of version 1.4.200, multiple connections occassionally shows error on the console of the form + ``` + org.h2.jdbc.JdbcSQLNonTransientException: General error: "java.lang.NullPointerException"; SQL statement: + SELECT image FROM challenge c, mapId m WHERE c.token=m.token AND m.uuid = ? [50000-200] + ``` + */ private val dbConn: DBConn = new DBConn() private val maxAttempts = 10 val tlStmts: ThreadLocal[Statements] = ThreadLocal.withInitial(() => new Statements(dbConn, maxAttempts))