Accessing database connection object from session or servlet

Hi, I am having a little trouble. I have created a pool of database connections in the servletInitialized() method of my servlet and I have successfully taken a database connection from the pool in the sessionInit() method. I am using the Apache KeyedObjectPool library for this.

However, I am a little unsure of how best to access the database connection object from the UI. Should I be using VaadinSession.getCurrent().getSession() or some other route?

I am learning Java at the same time as Vaadin so may be struggling with something that is obvious to most of you! The Book of Vaading seemed to cover this in chapter 11.14 but then stopped short.

Thanks in advance for any help you can give.

Create your own service and assign him with your entities (you can use Spring Integrity to do this) or use DriverManager class, eg.:

Connection connection = DriverManager.getConnection(“db_name”, “username”, “password”);

There are many methods to solve your problem.

I have no need of the DriverManager class or at least I don’t think so. My connection pooling is working fine.

Really all I need to know I suppose is how best to use an object instance that I have created in the Vaadin Servlet from my UI. I can store objects in my session using setAttribute() and then retrieve them using VaadinSession.getCurrent().getSession().getAttribute() and I’d like an equivalent way to access object instances from the servlet itself because that is where I’d like to store my connection pool.

Did you ever get a suitable response to this?