• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC in Action class...???

 
Varun Narang
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello every one,
I have a query. Can anyone tell me if it's a good idea to put JDBC code in the Action class or it'll be better to put it in a different POJ class.
Any answers will be highly appriciated.
Regards,
Varun Narang.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34860
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Varun,
It's better not to have JDBC in the Action class for the same reason it is better not to have it in a Servlet. In general, you want to keep your web layer and database layer in different classes. This makes it easier to change them independently of each other.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Jeanne. One of the main reasons for using Struts is to assist you in following the Model/View/Controller (MVC) pattern. An Action class belongs in the controller space, and classes that are tied to the Database generally belong in the Model space. You want to separate controller functions from model functions.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic