This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
If you are using connection pool, then what is the need to load connections at startup?? The pool will automatically contain connection for you to use. Anyways why do you want to do this with only an action not a ServletContextListener or load-on-startup servlet??
Kousik Majumder wrote:But here I have to use an Action class to use getDataSource(req,key) function. Is there any way to declare a Action class so that it can load some DB connection at server startup.
Once you define the data source in context.xml, then it automatically get connection pool at web app deployment. What you need is model as DAO(Data Access Object) getting the connection object thru JNDI(InitialContext) [This is may be considered as summary of the link I had given]