My questions are:- 1. calling Database connectivity (dbconnect()) in init is a better approach?
2. or shall i call it in service? 3. In case i have to make more than one connection objects. I think better would be to have connection pooling. Can you give me a good reference literature for same 4. If I go for connection pooling where should i call it - Init or service regards, Arun
You should go for a connection pool and only try to get a connection when a request comes in. If you do it in the init method, there is every chance that the DB will close the connection due to inactivity. Try going to java.sun.com and doing a search on connection pool. Incidently, having all these as instance variables:
can only lead to disaster when more than one request is executing at the same time. Bill [ April 03, 2002: Message edited by: William Brogden ]
Thanks William for your reply. BUt I think Service is suppose to be a synchronized method and if I made all other method in servlet as synchronized which (deals with database) will it still have a chance of crash in case more than one request is going through? regards, Arun