File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Optimizing sevlet performance with a database

 
Tod Checker
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello I have a design question.
Where is the best location on a servlet to access a database (assume a connection pool exists), and is database activity optimal when synchronized or left alone, for a high volume site?
When I say location on a servlet I mean, is it best to just write it in the service methods?
Or
Is it better to write it in its own method outside the service method?
Or
Is it better to write it in its own class which is instaniated and called within a service method or in singleton class which is shared among the site?
And is performance boosted if synchronization is used?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64183
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your application follows an MVC pattern (and it should), database access should be abstracted away from the servlet, which is part of Controller, into classes that are part of the Model.
Synchronization never improves performance. You synchronize to prevent thread safety issues, not to boost performance.
 
Tod Checker
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you think it is best to leave them in seperate classes and instaniate them in the service classes?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic