Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Getting connection from a Java class rather than a servlet?

843835Jul 23 2002 — edited Jul 26 2002
Hello,
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 23 2002
Added on Jul 23 2002
17 comments
299 views