Where to store db connection

Hi,

I am developing my first vaadin application and I am using MongoDB as the database store. I want to create a single MongoClient instance to use for all db requests. The MongoClient maintains a pool of connections.

I am unsure where I should create the MongoClient object and where I should store it so that I can get it later. Should I create it in my UI class? Where can I store it?

Thank you for any advice.

I think I found the answer in a demo project. I create and store the connection in the UI class that is my application’s entry point.

Then I can access in my View class by getUI().dbconn.