I am using hibernate framework for generating excel reports using JXL Api.
I was using default connection pooling mechanism provided by hibernate, however, i noticed that even though i close sessions, connections and resultsets, there were many connections that remained idle and as a result after some time my Oc4j server goes out of memory.
Is there anyway i can use a single connection for all requests with hibernate ?
I also implemented C3p0 connection pooling, i downloaded latest jar file and configured as per below, but the problem still persists,
Even though max_size property is configured, it still opens new connections above range 25.
Ujjwal B Soni <baroda, gujarat, india> <+918866008962>
"Helping hands are better than praying lips......"
The default connection pool is (by the Hibernate developer's own admission) not really production quality. Its just there to get you going.
Hibernate is just grabbing the amount of connections available to it based on the connection pool's configuration. If you want to just use one connection, configure the pool to just have one available. Hibernate will return connections to the pool when you close a Session. Are you closing Sessions?
That is an odd method you have there. Why are you combining ResultsSets, Statements, Connections and Sessions? And can you call flush() after you have closed the Session? It may be possible, but it seems illogical.
Disconnect will also disassociate a session from a connection.
In Hibernate you would not normally use Statements, ResultsSets of Connections directly - it kind of defeats the purpose of using Hibernate in the first place. Why are you choosing to do this?
If you use Hibernate as it is intended to be used, closing the Session releases database resource s back to the pool.
Joined: Mar 28, 2007
I am having an existing system that was built using hibernate, this system calls stored procedures and functions directly using connections. Thats the reason i need that function to close connection, session and resultset. There are very few HQL queries in the system.
Is it a good idea to remove hibernate and use JDBC directly using servlet filter to work on a single connection ?
If you have more than a few stored procedures to use, Hibernate is a little pointless (unless you have a longer term plan to remove these SPs). You are tightly coupled to your database implementation, so an ORM is just an overhead. I'd use JDBC.
Joined: Mar 28, 2007
Ok, thanks Paul...I think i should remove hibernate from the system and use Jdbc with servlet filter.