This week's book giveaway is in the General Computing forum.
We're giving away four copies of Learning Regular Expressions and have Ben Forta on-line!
See this thread for details.
Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Static methods in Data Access Object  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
author & internet detective
Sheriff
Posts: 38572
661
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sam Chako
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!