Getting connection from a Java class rather than a servlet?
843835Jul 23 2002 — edited Jul 26 2002Hello,
I have a servlet called EmployeeServlet which is used to display graphs, i have another class called Employee which will connect to the database and have the data in the object. Servlet gets its data from the Employee object and displays the graphs. I know it is preferred to create a connection object in the init() method of a servlet and reuse the object for a better performance.
How about in the Employee class, any suggestions as to where i should create a connection object?
Is it a good idea to use a connection object as an instance variable?
Also when is it appropriate to close a connection in the Employee class?
Any input is much appreciated.
Regards,
Navin Pathuru