aspose file tools*
The moose likes JDBC and the fly likes Caching Database Rows Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Caching Database Rows" Watch "Caching Database Rows" New topic
Author

Caching Database Rows

Alec Lee
Ranch Hand

Joined: Jan 28, 2004
Posts: 569
Just wondering if there is any built-in support of caching database rows in JDBC. Currently, if there is some rows to be accessed repeatedly, to reduce the number of SQL calls, I will manually create a Map containing the rows with the Map's key=PK of the table. But maintaining the cache manually looks tedious so just want to know if JDBC already providing help in this area.

Thx
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 31062
    
232

Alec,
JDBC doesn't provide caching built in. The database itself does caching, but then you still have to make a call to the database tier.

Your custom cache is a good way to go. You could do it as a wrapper around JDBC so all the code is in one place.


[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
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

Alec,

you can opt for CachedRowset, It is basically a disconnection rowset

Shailesh


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 861
I have cached ResultSets as arrays: Object[][].

One advantage of this approach is that I also have an API that allows you to easily query and sort the array that is in cache (A limited sql syntax but still very handy).



For more info go to http://www.fdsapi.com. There are a couple powerpoints to the left that discuss ArraySQL. I also have a class called ResultSetConverter that puts a ResultSet into an Object[][].
[ May 26, 2005: Message edited by: steve souza ]

http://www.jamonapi.com/ - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Caching Database Rows