Q:

Ibatis + j2ee + web service layer + statless bean

I have a j2ee project using ibatis to connect to the database and stateless bean to create web service and it works but i have a doubt
every time i call the service:

parse the ibatis xml configuration file. 
ibatis connect to the database
and generate the query. 

It is possible to avoid 1 and 2?  or at least 1? 
What is the correct way to do it?. 
I think that may be it is possible to call the ibatis xml once in a stateful ejb? 
Thanks. 

A:

Logically speaking, the configuration file should be parsed only once and the resulting object be stored in an application scoped variable.  The simplest but frowned upon way for that would be using Singletons.  The preferred way would be to use some sort of dependency injection framework like Guice or Spring. 
iBatis would require a connection object to connect to the database so this can't be avoided.  How are you currently handling connection management in your code? 