aspose file tools*
The moose likes Servlets and the fly likes servlet calling a database access file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet calling a database access file" Watch "servlet calling a database access file" New topic
Author

servlet calling a database access file

nash avin
Ranch Hand

Joined: Nov 13, 2003
Posts: 96
Hi,
I have a servlet in which all the code for database is present.This is a bad idea i am told,so I was suggested that I move all the database connection code to another class and make the server call that class(make an instance of the class).
Now the servlet class I have has the init() method and doPost() method.In the init() method I have

In the doPost() method I have the following code



My question now is,Do I have to just put what ever code is in the doPost() method into a separate .class file.Or do I have to put both the contents of doPost() and init() methods into another .class file.
Kindly let me know what could be a possible solution.Hope that I have told my problem properly.
Hoping to hear from you soon.
Thanks in advance
AS
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30938
    
158

I think it is better if both move to the separate class. Then your database code is all together, which is clearer.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
Don't get me started about those stupid light bulbs.
 
subject: servlet calling a database access file