wood burning stoves 2.0*
The moose likes JDBC and the fly likes Advantages of Reducing Database Hits Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Advantages of Reducing Database Hits" Watch "Advantages of Reducing Database Hits" New topic
Author

Advantages of Reducing Database Hits

jaffrin abdul salam
Greenhorn

Joined: Sep 16, 2005
Posts: 23
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?
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30929
    
158

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.


[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
jaffrin abdul salam
Greenhorn

Joined: Sep 16, 2005
Posts: 23
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
Marshal

Joined: May 26, 2003
Posts: 30929
    
158

Yes on both counts.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Advantages of Reducing Database Hits