• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Advantages of Reducing Database Hits

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The project that I am working on connects every end user to the database. We are using OracleOCIConnectionPooling for the logical connection. The issue here is for the error handling we are storing the error messages in the database. My question is " Is is good to load all the values at the application startup " so that it doesnt have to go the database each time when i want to retreive the error messages.
My team is opposing that, becuase they are saying that it will occupy the JVM memory and it slows down the application.
1. is that true?
2. when i deploy the application in a container where will be the JVM resides?
3.what is the difference between Server memory and JVM.
4.When I deploy the application in a container does all the class files will be in JVM? or it loads the class file whenever it needs.
5. If I create a HashMap and put all the error messages in the the HasMap , does it store it in the JVM? if its not JVM where does it stores.

For example in struts we have
MessageResources messageResources=getResources(request);
String message = messageresource.getMessage(key);
and it stores key and the vlaue in the HashMap. Does that mean it stores in the JVM?
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jaffrin,
This sounds like a case of premature optimization. If the error messages don't change, they are good candidates for caching. Unless there are hundreds of them, they are unlikely to use up any significant amount of memory (presuming you have a server application.)

As to your questions:
1) Yes. Storing anything uses memory. Retrieving from the database uses CPU and I/O. These tend to be the bottlenecks in an app. If you have a very large number of error messages, you could cache them on first use rather than all at once.
2) The JVM is on the server.
3) It depends how the terms are used. Essentially you care about JVM memory.
4) Class files are loaded upon first use. Class files almost never cause a memory issue. Especially on a server.
5) Yes, it stores them in the JVM.

And yes, Struts stores data in the JVM.

I think your best question is to find out how big this data actually is. From the questions, it sounds like worrying about a non-issue though.
 
jaffrin abdul salam
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Jeanne!
I really appreciate your help. Please calrify me for the following.
1. Storing the datas in the JVM is not a problem but it depends on how big the data is? If it is very Huge than storing it in the database is better option?
2. If the data is not big then store it in the HashMap that is in JVM?
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes on both counts.
 
Talk sense to a fool and he calls you foolish. -Euripides A foolish tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic