-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: PreparedStatement leak in Oracle
PostPosted: Wed Dec 08, 2004 6:12 pm 
Newbie

Joined: Wed Dec 08, 2004 6:04 pm
Posts: 4
Hibernate version: 2.1.6

Name and version of the database you are using: Oracle 8 (with Oracle 9 JDBC drivers, for less-buggy CLOB support)

Hi folks,

A customer is reporting that one of our periodic tasks is leaking cursors. Of course, we don't observe the same problem with MySQL. Here's the code that appears to be responsible:

Code:
       
                Session session = null;
                Connection conn = null;
                PreparedStatement ps = null;
                ResultSet rs = null;
                try {
                    session = getSession();
                    conn = session.connection();
                    ps = conn.prepareStatement("DELETE FROM table WHERE field < ?");
                    ps.setLong(1, value);
                    int num = ps.executeUpdate();
                    if (num > 0) logger.fine("Did stuff " + num + " times");
                    conn.commit();
                    conn = null;
                } finally {
                    if (conn != null) try {
                        conn.rollback();
                    } finally {
                        if (rs != null) try {
                            rs.close();
                        } finally {
                            try {
                                if (ps != null) ps.close();
                            } finally {
                                if (session != null) session.close();
                            }
                        }
                    }
                }


I'm using C3P0 0.8.5pre4 and I've tried turning off its PreparedStatement cache, to no effect. Am I doing something obviously wrong here?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 08, 2004 6:19 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
What is leaking cursor ? What is your error ? - try increase open_cursors parameter

regards


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 08, 2004 6:23 pm 
Newbie

Joined: Wed Dec 08, 2004 6:04 pm
Posts: 4
snpesnpe wrote:
What is leaking cursor ? What is your error ? - try increase open_cursors parameter
regards

It's the "DELETE FROM..." PreparedStatement that's creating the leak. The customer eventually sees the "too many open cursors" error from Oracle.

It doesn't really matter what the maximum allowed open cursors is, since they're not supposed to last that long anyway.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 08, 2004 6:29 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
It isn't code which get 'too many open cursors' - it open and close true one cursor - we have another problem
for every case increase opne_cursors - it can be > x000

regards


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 08, 2004 6:30 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
parameter is open_cursors
and . your code isn't hibernate - it is jdbc code


Top
 Profile  
 
 Post subject: Fixed, stupid mistake, never mind
PostPosted: Wed Dec 08, 2004 8:27 pm 
Newbie

Joined: Wed Dec 08, 2004 6:04 pm
Posts: 4
snpesnpe wrote:
parameter is open_cursors
and . your code isn't hibernate - it is jdbc code

You're right, it isn't, but I was thinking that maybe Hibernate and/or C3P0 was holding on to some resources. Actually there was a really stupid bug in my code. Thanks for taking the time to help anyway. :)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 08, 2004 8:40 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
make only one finally


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.