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 What is Caching ? 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 "What is Caching ?" Watch "What is Caching ?" New topic
Author

What is Caching ?

Kaleeswaran Karuppasamy
Ranch Hand

Joined: Jul 19, 2007
Posts: 154
Dot.net guys said they are using Caching tecniques in database access.In dot net Retrieve all data from particular table or Database into temp memory at a time, this more fast.

However in java how we are achieving this techniques.
my knowledge
1.Using CachedRowSet
2.Using hibernate

please tell me which technique?


Judge a man by his questions rather than his answers --Voltaire
SCJP 1.5 97%
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

In memory caching is just moving data from your database into memory. The simplest way to do it is to copy the contents of a ResultSet into a Collection. Of the two techniques you mention a CachedRowSet is pretty much just that. Hibernate on the other hand is not a caching mechanism, it is an Object Relational Mapping tool that includes various different types of cache. The need for caching alone is not a reason to use it.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Kaleeswaran Karuppasamy
Ranch Hand

Joined: Jul 19, 2007
Posts: 154
Originally posted by Paul Sturrock:
In memory caching is just moving data from your database into memory. The simplest way to do it is to copy the contents of a ResultSet into a Collection. Of the two techniques you mention a CachedRowSet is pretty much just that. Hibernate on the other hand is not a caching mechanism, it is an Object Relational Mapping tool that includes various different types of cache. The need for caching alone is not a reason to use it.


But Copying all table values into arraylist is very slow compared to direct access of database right?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

No. In most JDBC applications the bottleneck will be the connection to the database, not what is going on in memory. It is a common pattern to open a ResultSet, iterate through it copying each row into another data structure then close the ResultSet.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30068
    
149

Originally posted by kalees waran:


But Copying all table values into arraylist is very slow compared to direct access of database right?

No. The arraylist is just memory access. The database involves both network traffic (if on a different machine) and file system I/O.


[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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What is Caching ?
 
Similar Threads
Hibernate Caching
cache and pool
JPA and multiple JVMs - refresh problems
Why use MemCache for database results caching when hibernate and spring does it all
Alternative to properties file