Resultset alternative

Discussion in 'Java' started by miche, Jun 21, 2007.

  1. miche

    miche Guest

    If I work with a ResultSet, I must leave open my statement because if
    I close the statement, automatically close also the relative
    ResultSet. What can I use if I don't want leave the statement open but
    I want work totally disconnect?

    Thanks in advance!
    Miche!
     
    miche, Jun 21, 2007
    #1
    1. Advertising

  2. miche

    stefanomnn Guest

    with jdbc 3.0 you can use CachedRowSet class, which provide you a
    disconnected ResultSet. here's a snippet:

    Code:
    Statement stmt = con.createStatement();
    ResultSet rs =  stmt.executeQuery(
                  "SELECT COF_NAME, PRICE FROM COFFEES");
     CachedRowSet rset = new CachedRowSet();
     crset.populate(rs);
     rs.close();
     stmt.close();
    
    if you can't, you could create a collection of Map, where a map is a
    row.

    Stefano
     
    stefanomnn, Jun 21, 2007
    #2
    1. Advertising

  3. miche

    miche Guest

    stefanomnn ha scritto:

    > with jdbc 3.0 you can use CachedRowSet class, which provide you a
    > disconnected ResultSet. here's a snippet:
    >
    >
    Code:
    > Statement stmt = con.createStatement();
    > ResultSet rs =  stmt.executeQuery(
    >               "SELECT COF_NAME, PRICE FROM COFFEES");
    >  CachedRowSet rset = new CachedRowSet();
    >  crset.populate(rs);
    >  rs.close();
    >  stmt.close();
    > 
    >
    > if you can't, you could create a collection of Map, where a map is a
    > row.
    >
    > Stefano


    Hi Stefano

    You are very kind...
    I can try your suggestion...

    Thank you so mutch!
    Michele

    bye bye
     
    miche, Jun 21, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matrix
    Replies:
    0
    Views:
    596
    Matrix
    Apr 1, 2004
  2. matrix ¿ìÀÖÄñ

    How i know the size of "resultset"?

    matrix ¿ìÀÖÄñ, Apr 3, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    3,479
    matrix ¿ìÀÖÄñ
    Apr 3, 2004
  3. =?Utf-8?B?VGltX2s=?=

    Web Treeview loaded from resultset example

    =?Utf-8?B?VGltX2s=?=, Jun 18, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    348
    =?Utf-8?B?VGltX2s=?=
    Jun 18, 2004
  4. =?Utf-8?B?VGltX2s=?=

    Web Treeview loaded from resultset example

    =?Utf-8?B?VGltX2s=?=, Jun 18, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    270
    =?Utf-8?B?VGltX2s=?=
    Jun 18, 2004
  5. Joe via DotNetMonster.com

    Multiple Select Statements in resultset

    Joe via DotNetMonster.com, Mar 26, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    8,227
    Jim via DotNetMonster.com
    Mar 27, 2005
Loading...

Share This Page