Manipulating a resultSet for mutiple use
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Manipulating a resultSet for mutiple use

Hybrid View

  1. #1
    Join Date
    Jun 2011
    Posts
    2

    Manipulating a resultSet for mutiple use

    I have worked with this a couple of times, and got it to work using an Array, but I wanted to try it in a different way. Basically I have a query that would give me these DB results:

    ID CODE DESCRIPTION1 POS SORTER DATE
    ---- ------ ---------------- ----- -------- ------
    WEB 2003SP Spring 2003 1 1 1-1-2003
    WEB 2003FL Fall 2003 2 1 8-1-2003
    WEB 2003SU Summer 2003 3 1 5-1-2003
    WEB 2003Q1 Quarter 1 2003 4 2 1-1-2003
    WEB 2003Q2 Quarter 2 2003 5 2 4-1-2003
    WEB 2003Q3 Quarter 3 2003 6 2 7-1-2003
    WEB 2003Q4 Quarter 4 2003 7 2 10-1-2003

    So, what I was wanting to do now, is use these results to populate my HTML table. Here is how I was looking at populating the table (take a look at the comments in the code):

    Code:
       <table>
        <tr>
          <td>Terms</td>
          <td>Date</td>
        </tr>
        <tr>
          <td colspan="2">UG Terms</td>
        </tr>
        <tr>
          <td>All Sections</td>
        <tr>
          <td>  <!-- HERE I WOULD WANT TO PRINT ALL TERMS WHERE SORTER = '1' --></td>
        </tr>
        </tr>
        <tr>
          <td>Other Sections</td>
        </tr>
        <tr>
          <td><!-- HERE I WOULD WANT TO PRINT ALL TERMS WHERE SORTER = '1' --></td>
        </tr>
        <tr>
          <td>Winter</td>
        <tr>
          <td><!-- HERE I WOULD WANT TO PRINT ALL TERMS WHERE SORTER = '1' and REPRESENTATION.substring(0,5) = 'Spring' --></td>
        </tr>
        </tr>
        <tr>
          <td>Summer</td>
        <tr>
          <td><!-- HERE I WOULD WANT TO PRINT ALL TERMS WHERE SORTER = '1' and REPRESENTATION.substring(0,5) = 'Summer' --></td>
        </tr>
        </tr>
        <tr>
          <td colspan="2">Other Terms</td>
        </tr> 
        <tr>
          <td>All Sections</td>
        </tr>
        <tr>
          <td><!-- HERE I WOULD WANT TO PRINT ALL TERMS WHERE SORTER = '2' --></td>
        <tr>
      </table>
    So again, Where the comments are is how I want to fill out the table, I am thinking this is possible, and I was just wondering how to go about doing this. Thanks for the help, and if more info is needed, please let me know.

  2. #2
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: Manipulating a resultSet for mutiple use

    Could you clarify what your Java problem is? This looks like an HTML/Javascript problem...

    There is nothing so useless as doing efficiently that which should not be done at all...
    P. Drucker
    Please use &#91;CODE]...your code here...&#91;/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  3. #3
    Join Date
    Jun 2011
    Posts
    2

    Re: Manipulating a resultSet for mutiple use

    The "java question" is how to manipulate a resultset in the ways listed from the Original Post. As far as I know, it isnt a javascript question. It does involve HTML, because that is where the results are going (an HTML table), but the true question is about java. I apologize if it wasn't clear, but I am looking for help with manipulating a resultset in the way that is listed on the comments in the code

  4. #4
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: Manipulating a resultSet for mutiple use

    You use a ResultSet by iterating over it by row (using the next() method) and extracting column values using the getXxxx() methods. By default, it's a one-way, one-time iteration, so if you want to use the data multiple times with different filters, you should extract it into suitable local storage - usually a class instance per row, stored in an ArrayList.

    How you actually put this data into a HTML table depends on the context - e.g. for a web server operation you might use JSP, or a servlet; or outside a server, you might just have a String containing HTML into which you want to insert values at the specified points...

    Everything should be made as simple as possible, but not simpler...
    A. Einstein
    Please use &#91;CODE]...your code here...&#91;/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center