tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From William Wragg <will...@datapro.co.uk>
Subject Re: DB Connection
Date Wed, 28 May 2003 09:28:57 GMT
What you might want to try is storing the ResultSet in the session, and 
closing the ResultSet when the session is closed or the ResultSet is 
removed from the session. I looked into this, but eneded up going down the 
copying route. To store a ResultSet in the session what I came up with is 
the following:

The object you use to make the connection and retrieve the ResultSet needs 
to implement the HttpSessionBindingListener. The object also needs to store 
the ResultSet i.e. it doesn't pass it else where, and allow public access 
to it. You put the closing of the ResultSet and connection into the 
valueUnbound method of the object, which gets called when the session is 
invalidated (via a timeout say) or the object is removed from the session.

Just a word of warning if you decide to go down this route, a connection 
can be left in the session until it times out, which can mean that all the 
connections in the pool can be tied up in unused sessions until they start 
to timeout.

Regards,

Wm.

At 09:12 28/05/2003, you wrote:

>Guys, this is very interesting discussion.
>I have read all the posts.
>I still have another problem.
>What about VERY large Result Sets?
>I have a portal with 1 000 000 records[books related].
>When the user searches for romance, there are more than 200 000 records
>returned.
>I can't use CachedResultSet [I would have to hold all this in memory, in an
>object registerd in the HTTPSession]
>also I can't use the ArrayList.
>I am also using a DB pool system and I want to return the connection.
>Is there a solution? [better said an optimal solution].
>If the ResultSet doesn't hold all the records in memory[RAM],
>(setFetchSize(int) -> sets how many rows to be brought into memory), where
>is the rest? A concrete case:
>"select name from books" -> returns 850 000 records.
>statement->setFecthSize(25);
>the rest of 849975 records are left in the database?, on the hard-disk? or
>the database is making all this resultset
>internally, and itself uses RAM and some swap? Does anyone knows all this
>internal action, how it is going on?
>
>Comments, URLs appreciated.
>Info: I use Postgresql if it counts.
>In the case that I will have to not return the connection to the pool, and,
>because ResultSet doesn't hold in memory all the records I would save it int
>the HTTPSession, HOW AM I going to know when to release it and return the
>connection to the pool?
>
>Thank you very much in advance.

Mime
View raw message