Suppose I run a website that handles services such as user registration, user login checks, etc. I have all the credentials stored in an ObjectDB.
Currently, each time user sends a request, I initiate a db connection by creating entity manager factory from db on disk, get the entity manager, modify stuff, close the connections.
I wonder if it is better to have an overall db manager created on server init, then provide the shared instance over all requests, instead of creating a new one every time.
Out of curiosity, is my current method thread-safe? Can multiple entity managers exist at the same time?