minor: added comment about per thread connections

This commit is contained in:
hrj 2021-04-12 17:01:24 +05:30
parent 79428bc5e7
commit f8de5a5932

View File

@ -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))