Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: 10GR2 vs. 10GR1 Java Open Cursor Differences

RE: 10GR2 vs. 10GR1 Java Open Cursor Differences

From: Borrill, Christopher <Chris.Borrill_at_hp.com>
Date: Thu, 11 Jan 2007 15:44:17 +1300
Message-ID: <94941EE84F6FCD43B55C5B64DD0DAC6A0406B931@nzmexc01.asiapacific.cpqcorp.net>


When a statement is closed the JavaDoc says that its current ResultSet is closed:

http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Statement.html#close()

Another possible issue with this code snippet is that if an exception occurs between the statement being create (stmt = connection.prepareStatement) and closed (stmt.close()), the close will not occur as there is no finally block. Normally the following structure is good practice as shown in "Proper Closure of Database Resources" in this article:

http://www.oracle.com/technology/pub/articles/marx_spring.html

Regards,
Chris Borrill

-----Original Message-----

From: oracle-l-bounce_at_freelists.org
[mailto:oracle-l-bounce_at_freelists.org] On Behalf Of MacGregor, Ian A. Sent: Thursday, 11 January 2007 12:14 p.m. To: oracle-l_at_freelists.org
Subject: 10GR2 vs. 10GR1 Java Open Cursor Differences

Since Moving to 10,2 some open cursor problems have surfaced. Here's an example of the code:

        // collect the ProcessInstances in this Stream's ParentStream that depe nd (status transition) on ProcessInstances within this Stream:

         stmt = connection.prepareStatement("select PI.ProcessInstance from Proc essInstance PI, Process P, ProcessStatusCondition PSC where PI.Stream = ? and PI .Process = P.Process and P.Process = PSC.DependentProcess and PSC.Process in (se lect Process from Process where Task = ?) and PI.IsLatest = 1");

         stmt.setInt(1, parentStream);
         stmt.setInt(2, task);
         rs = stmt.executeQuery();
         while (rs.next())
            processInstanceSet.add(new
Integer(rs.getInt("PROCESSINSTANCE")));
         stmt.close();


I'm not a Java person. I did noticeThe code has no rs.close() statement. The developer admits that he doesn't explicitly close the results set. The trouble is that he swears it all worked in 10GR1 and the users testing the system back him up.

The code is indirectly recursive; A calls B which calls A and may nest several times.

Ian MacGregor
Stanford Linear Accelerator Center
ian_at_slac.stanford.edu

I
--

http://www.freelists.org/webpage/oracle-l

--

http://www.freelists.org/webpage/oracle-l Received on Wed Jan 10 2007 - 20:44:17 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US