wood burning stoves 2.0*
The moose likes Performance and the fly likes Static methods in Data Access Object Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "Static methods in Data Access Object" Watch "Static methods in Data Access Object" New topic
Author

Static methods in Data Access Object

Sam Chako
Greenhorn

Joined: Jan 28, 2003
Posts: 7
Hello,

I am calling static methods in a DAO (for database updates and select) from a stateless session bean; i.e. in the ejb I have method calls to DAO like:

DAO.update(String str1, String str2, .....);

If there are many concurrent users for this particular static DAO method, will performance be affected? How can I overcome this bottleneck?

Thanks in advance,
Sam.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30405
    
150

Sam,
I would make the DAO methods non-static to make reuse and testing easier, but that won't have any impact on performance.

The performance problems should primarily come from connecting to the database, executing the query and transfering data across the network. Since you are working with updates, there could also be contention problems.

Look into your connection pool settings and transaction settings to increase performance under load. Also, make sure your update is optimized.


[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
Joel Naten
Greenhorn

Joined: Aug 07, 2004
Posts: 5
You should let the database or EJB container handle the concurrency by use of transactions. That will be your major issue for performance bottlenecks. It will depend on what you need to change, and how you go about it.


<a href="http://www.blogeasy.com/" target="_blank" rel="nofollow">Free Blog</a> | <a href="http://www.blogeasy.com/" target="_blank" rel="nofollow">Free Blog Site</a>
Sam Chako
Greenhorn

Joined: Jan 28, 2003
Posts: 7
Thanks Jeanne and Joel,

I think I understand why I should use EJBs to take care of the concurrency problem.

Your comments have been extremely helpful !!

Thanks again,
Sam.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Sam Chako:
I think I understand why I should use EJBs to take care of the concurrency problem.


I would actually argue that you *shouldn't* use EJBs just to handle concurrent data base access. There are much more simply options available, such as using a persistence library like Hibernate or even simply using JDBC to handle transactions.

I needed to have much more compelling reasons to go with the complexity of EJBs - in such a case, I would use the transaction handling of the EJB container, of course.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Static methods in Data Access Object