This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Static methods in Data Access Object  RSS feed

 
Sam Chako
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.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37242
519
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.
 
Joel Naten
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.
 
Ilja Preuss
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!