This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes cache Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "cache " Watch "cache " New topic


Hari babu
Ranch Hand

Joined: Jun 25, 2001
Posts: 208
I want to cache the resultset information got by executing a query "Query1". Now when i exceute "Query1" again i want to read from the cache instaed of making a database call again. Do i have to do this explicitly in my application where-in i check in the cache for data if not found then i query the Database or this process is done implicitly.
In either case, explicit or implicit loading,the cache can only serve the purpose only if the "Query1 " is exceuted for the 2nd time if not, my cache is useless (Hope iam correct). So what is the better way of doing things and when to go for cache (Will it be helpful in this scenario ??)
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1121

Hi Babu,
I don't know what databases you are planning on working with (since I saw no mention of that in your post), but I know that this is the default behaviour with the Oracle database that I work with (version on SUN [sparc] Solaris 7).
The database has a cache where it keeps query results. So the second time you execute the same query, if the results are still in the database cache, then the data in the cache is what is returned.
I would imagine that other databases behave the same way.
So why would you want to implement this behaviour yourself? Even if you insisted on implementing this behaviour yourself, my guess is that the database's implementation is probably much better than what yours would be -- don't you think?
Hope this has helped you.
Good Luck,
Don't get me started about those stupid light bulbs.
subject: cache
Similar Threads
Relation between Hibernate Query Cache and Second Level Cache
Escape Character Help
Prepared Statements
Hibernate second level cache questions
hibernate cache