Hi,
> this means that when I get a connection from the servletContext, I get
> a non-pooled connection, and always the same one is used.
Yes.
> - it is safe to access the same connection from multiple threads?
No.
> How this works with transactions?
If you use transactions, you have to synchronize on the connection.
> what happens if programmers calls connection.close() after usage
Then the connection is closed.
> - why not using a servletContext.setAttribute("pool", connectionPool),
> which looks more suitable -to me- for a web application?
You can do that of course.
> Am I missing something special that makes this approach valid for H2 ?
> (and invalid for all other databases I know of)
Both approaches are valid for any database. Using a ConnectionPool is
nice, and has advantages. Maybe I will change the code to use a
connection pool, or having the option of a connection pool.
Regards,
Thomas