| Author |
What is Caching ?
|
Kaleeswaran Karuppasamy
Ranch Hand
Joined: Jul 19, 2007
Posts: 151
|
|
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: 151
|
|
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: 26141
|
|
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: jrebel
|
|
subject: What is Caching ?
|
|
|