Re: Is perl better? :(((

From: Lee Fesperman (firstsql_at_ix.netcom.com)
Date: 02/05/05


Date: Sat, 05 Feb 2005 03:27:53 GMT

Chris Smith wrote:
>
> steve <me@me.com> wrote:
> > it will stop ( well actually sql crash , and it would kill any other program
> > on the server that tries to open a cursor ) after 300 cursors are left open.
> > not the way to run on a production system.
>
> Steve, you're a little late here, but just to clarify: that's not true.
> Omitting rs.close() in the code mentioned here will not leave open
> cursors anywhere, because the cursor will be closed when the next loop
> iteration calls PreparedStatement.execute(). The last cursor is closed
> when the connection is closed.

That's what the spec says, but I think that closing resultsets is needed for some
backends (Oracle). Also, you should close the prepared statement instead of waiting for
the connection to do the job. IOW, the best practice is always close resultsets,
statements and connections and do it as soon as you don't need them anymore. For a
decent backend, this should not be more costly and will free up resources on the server
... to everyone's benefit.

-- 
Lee Fesperman, FFE Software, Inc. (http://www.firstsql.com)
==============================================================
* The Ultimate DBMS is here!
* FirstSQL/J Object/Relational DBMS  (http://www.firstsql.com)


Relevant Pages

  • Re: Is perl better? :(((
    ... The last cursor is closed ... > when the connection is closed. ... you should close the prepared statement instead of waiting for ... FirstSQL/J Object/Relational DBMS ...
    (comp.lang.java.programmer)
  • Re: Huge memory comsumption of ADODB Connection object
    ... Why I said the Connection ... to nothing, the memory used by my app doesn't decrease, only when I close the ... I take the same opinion as you do, if the cursor doesn't return ... resultset to client, no impact will be imposed to client. ...
    (microsoft.public.data.ado)
  • Re: VB6 ADO DB2 - Update Problem
    ... Jeweils ein Feld der beiden ... Was veranlasst Dich zu der Annahme, dass Daten eines Recordsets mit ... Man kann eine Connection auch ohne ein solches Ungetüm öffnen, ... Warum serverseitiger Cursor? ...
    (microsoft.public.de.vb.datenbank)
  • Re: SelectMethod=cursor and SelectMethod=direct
    ... Produced By Microsoft MimeOLE V6.00.2900.2180 ... After processing a resultset the prepared statement is ... | concern is the memory usage as a direct cursor reads the complete ... |>> Frank Brouwer ...
    (microsoft.public.sqlserver.jdbcdriver)
  • Re: psycopg, transactions and multiple cursors
    ... >> opening a connection thus the app doesn't suffer so much. ... first time a change is made to the database. ... >> what you want is a nested and not a new cursor. ... B e careful that you don;t confuse the DB API curosrs with the cursors ...
    (comp.lang.python)

Loading