Creating subset of ResultSet

I'm working with a product that uses a jdbc driver, but it isn' jdbc 2.0. It's an earlier version, although I'm not sure; probably the version before 2.0. I need to grab a subset of a resultset (all the rows, but only some of the columns). What's the easiest way of doing this? Thanks.

Easiest way of doing that is to use the ResultSet as
is and ignore the columns you don't want. Or am I
missing something?I thought there might be something similar to getArray (jdbc 2.0 method). I have to filter a couple of different looking resultsets, and thought there might be an easy way to do this, without looping through the whole resultset and picking out only what I need.

Similar Messages

  • How to create a PreparedStatement/ResultSet with a blank record?

    I want to query my database and if no records are found I want to have a valid result set filled with blanks (or zeros) for the proper columns.
    For example, given this code:
    <pre>
    PreparedStatement statement = connection.prepareStatement(
    "SELECT * FROM address WHERE name = ?",
    ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_READ_ONLY);
    statement.setString(1,myAddress);
    ResultSet rs = statement.executeQuery();
    while (rs.next())
    System.out.println("Zip Code: '" + rs.getString("zip") + "'");
    </pre>
    If a record is found, the output would be
    <pre>
    Zip Code: '12345'
    </pre>
    If no record is found the output would be
    <pre>
    Zip Code: ''
    </pre>
    Can that be done easily by tinkering with the PreparedStatement or ResultSet?
    My fallback is to create a class that maps to the database and have the constructor handle the processing.

    818957 wrote:
    I want to query my database and if no records are found I want to have a valid result set filled with blanks (or zeros) for the proper columns.You seem to be mixing concepts here. Let's say you do select name, age from person and you get
    Joe     35
    Fred    40
    Mary    28Which of the following are you trying to do?
    1. If there are no rows matching the query, you want a single row with dummy values
    <blank name>   0If this is what you're trying to do, why? What purpose would that row serve?
    OR
    2. If a given column is empty (null) provide a default value
    Joe     0
            40
    Mary    28If this is what you want, it can be done easily, but it's a SQL question and has nothing to do with Java. Consult the SQL reference for your DB.
    (EDIT: Note this can also be done easily in Java, but it's a bit more code, and, IMHO, it's a less natural place to do it.)
    OR
    Something else? If so, please clarify.
    Edited by: jverd on Dec 7, 2010 1:28 PM

  • How to create updateable resultset using sql with "order by"

    Dear all,
    I'm using the Derby database to hold a table of stock prices. After the table is populated, I want to do some calculations and store the result in a column.
    I get the resultset using the following code
    Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet rs = stmt.executeQuery(select history_id, value, days from history where ticker = '" + ticker + "' order by value_date"); {code} When I then try to update the "days" field, I get an SQLException telling me that the resultset is not updatable. However, if I remove the "order by" clause, I am able to update the data, but then my algorithm does not work as I need to traverse the data in a specific order. The quesion is: how do I create an updatable resultset using a sql-statement with an order by clause? Kind regards Karl Martin Lund                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    jschell wrote:
    Seems rather obvious to me that the exception specifically tells you that you can't do that.OP: I would guess it's because ORDER BY forces the database to read all the result rows into a temporary area, sort them, and then return them from this temporary area, as opposed to streaming the results. The extra step probably makes updateable result sets more difficult (or maybe not possible), so they opted not to do it.

  • Mysterious closing ResultSets

    I'm getting desperate for a solution to this problem (as is the rest of the development team!).
    Basically we've been trying to create a system that automatically assigns values (frequencies) to objects (nodes) based on a rule set. Each node contains a varying number of sub-objects (radios) and each radio needs one frequency. The database has been set up and has test data for our Solution class to go through. However, we've run into an odd problem where our ResultSets are suddenly closing.
    The classes work like this:
    Database Broker (handles connection to DB, as well as executeQuery and executeUpdate statements.)
    Entry Broker (Holds all SQL statements for data retrieval in various methods. Each method contains an SQL statement to access data, and code to format that data into something useable by the main class.
    Solution/Main class (Contains methods to use the data from the Entry Broker to test valid solutions. Certain rules apply to assigning frequencies to radios and this class ensures that the data applies to these rules before it writes the data back to the DB (via the EntryBroker).
    The problem we continually run into is that whilst the ResultSets work fine in the Entry Broker, they are closed when they return to the Main class.
    Here's the catch: It seems in most cases that only the FIRST ResultSet returned in each method is closed, the remaining ResultSets work fine. We worked around this problem by creating a 'dummy' ResultSet, which obtained data from the database which was never used (the project name). We put this in its own try catch bracket so it would not interrupt the project.
    It worked fine for a few classes, but for others (notably the following one) it was ineffective. We've searched and searched but we cannot find anyone with a similar complaint (except a few people who have commented about ODBC version problems). Our ODBC version is 3.520.7713.0
    Here's an example method from the Solution class (The entire class is over 1000 lines):
    // Method to test Harmonic resonance for nodes within 10m
    private boolean resonanceGlobal (boolean tstResonanceG, double txFreq, double rxFreq, int distance)     {
    System.out.println("Beginning global harmonic resonance check");
    try {
    // Getting Nodes
    rsNode2 = eBroker.getNodes(projectNo);
    // node loop
    while (rsNode2.next())     {
    System.out.println("602 Test Marker GHarm 1");
    // get next node, store in nodeTemp
    nodeTemp = rsNode2.getInt(1);
    // System out to show which nodes will pass if statement
    System.out.println(node + " compare to " + nodeTemp);
    // avoid testing the same node against itself
    if (nodeTemp != node)     {
    // distance check (only neccesary within 10m)
    System.out.println("Test Marker Before Distance check");
    distance = getDistance(node, nodeTemp, distance);
    System.out.println("Test Marker After Distance check");
    // distance check if statement
    if (distance <= 10)     {
    System.out.println("618 Test Marker GHarm 2");
    // get the radios of the node, foreign node
    rsRadiosTemp = eBroker.getRadios(node);
    rsDummy = eBroker.getDummy(projectNo);
    rsRadios2 = eBroker.getRadios(nodeTemp);
    // This dummy ResultSet normally fails so that
    // the other ResultSets perform normally
    try {
    rsDummy.next();
    }     // end try
    catch (java.sql.SQLException dummyException)     {
    System.out.println("dummyException " + dummyException);
    }     // end catch
    // radio loop
    while (rsRadiosTemp.next())     {     // error occurs here
    System.out.println("627 Test Marker GHarm 3");
    // loop for foreign node radios
    while (rsRadios2.next())     {
    System.out.println("631 Test Marker GHarm 4");
    // get next radio
    radioTemp = rsRadios2.getInt(1);
    // get the TX and RX of the radio
    genericTX = getTX(radioTemp);
    radioTempCon = getConnection(radioTemp);
    genericRX = getTX(radioTempCon);
    // calculate bounds for harmonics test
    txLo = ((txFreq * 2) - genericTX) - 4;     // 4Mhz below TX harmonics check
    txHi = ((txFreq * 2) - genericTX) + 4;     // 4Mhz above TX harmonics check
    rxHi = ((rxFreq * 2) - genericRX) + 4;     // 4Mhz above RX harmonics check
    rxLo = ((rxFreq * 2) - genericRX) - 4;     // 4Mhz below RX harmonics check
    // checks TX and RX of foreign radio against TX, RX of current radio for separation
    if ((txLo > genericTX && txHi < genericTX) || (rxLo > genericRX && rxHi < genericRX))     {
    tstResonanceG = false;     
    break;
    } //end if
    else {
    tstResonanceG = true;
    }     // end else
    } //end foreign radio loop
    // breaking out of loops for return
    if (tstResonanceG == false)
    break;
    }     // end radio loop
    rsRadios2.close();
    rsRadiosTemp.close();
    }     // end sameradio check
    }     // end distance check
    }// end node loop
    rsNode2.close();
    }     // end try
    // Catch statement to stop from crashing in the
    // event of an error during SQL statements.
    catch (java.sql.SQLException resonanceGlobalException) {
    // Prints out the error message produced
    System.out.println(resonanceGlobalException);
    }     // end catch
    // returns result
    return tstResonanceG;
    } //end checkHarmonicResonanceGlobal()
    My apologies if it is a little hard to read, but the indenting is accurate. The Entry Broker methods which this method uses are here:
    public ResultSet getNodes (int projectNo) {
    // creating SQL statement
    sqlStatement = "SELECT nodeNo from tblNode WHERE projectNo = " + projectNo;
    System.out.println(sqlStatement);
    // executing SQL statement
    rsNodes = db.runQuery(sqlStatement);
    // returns ResultSet
    return rsNodes;
    }     // end getNodes
    // Method to get the distance between any two nodes
    public int getDistance (int projectNo, int node, int tempNode)     {
    ResultSet rsX1;                         // Used for obtaining the X-coord of node 1
    ResultSet rsX2;                         // Used for obtaining the X-coord of node 2
    ResultSet rsY1;                         // Used for obtaining the Y-coord of node 1
    ResultSet rsY2;                         // Used for obtaining the Y-coord of node 2
    double distance = 0;                    // Used in Global checks
    int dist = 0;                              // Used in Global checks
    int x1 = 0;                                   // Used in calculating distance
    int x2 = 0;                                   // Used in calculating distance
    int y1 = 0;                                   // Used in calculating distance
    int y2 = 0;                                   // Used in calculating distance
    int xDist = 0;                              // Used in calculating distance
    int yDist = 0;                              // Used in calculating distance
    int distint = 0;                         // Used to store converted values
    try {
    // get the X and Y co-ordinates of both nodes
    sqlStatement = "SELECT xCoord FROM tblNode WHERE nodeNo = " + node + " AND projectNo = " + projectNo;
    rsX1 = db.runQuery(sqlStatement);
    rsX1.next();
    x1 = rsX1.getInt(1);
    sqlStatement = "SELECT yCoord FROM tblNode WHERE nodeNo = " + node + " AND projectNo = " + projectNo;
    rsY1 = db.runQuery(sqlStatement);
    rsY1.next();
    y1 = rsY1.getInt(1);
    sqlStatement = "SELECT xCoord FROM tblNode WHERE nodeNo = " + tempNode + " AND projectNo = " + projectNo;
    rsX2 = db.runQuery(sqlStatement);
    rsX2.next();
    x2 = rsX2.getInt(1);
    sqlStatement = "SELECT yCoord FROM tblNode WHERE nodeNo = " + tempNode + " AND projectNo = " + projectNo;
    rsY2 = db.runQuery(sqlStatement);
    rsY2.next();
    y2 = rsY2.getInt(1);
    }     // end try
    catch (java.sql.SQLException getDistanceException) {
    System.out.println(getDistanceException);
    // calculating distance
    yDist = y2 - y1;
    xDist = x2 - x1;
    // perform pythagoras theorem for distance
    dist = (xDist * xDist) + (yDist * yDist);
    distance = java.lang.Math.sqrt(dist);
    Double roundFreqTemp = new Double(freqTemp);
    distint = roundFreqTemp.intValue() ;
    return distint;
    } // end get distance method
    // Method to get all the radios in a node
    public ResultSet getRadios(int node)     {
    ResultSet rsRadios;          // Used for obtaining radios in a node
    // creating sql Statement
    sqlStatement = "SELECT * FROM tblRadio WHERE nodeNo =" + node;
    System.out.println(sqlStatement);
    // executing sql Statement
    rsRadios = db.runQuery(sqlStatement);
    System.out.println("EB Test Marker 1: Line 261");
    // returning radio no
    return rsRadios;
    }//end getRadio
    public double getTX(int radioTemp){
    double txTemp = 0;     // Used for storing TX of a radio
    int freqNoTemp = 0; // Used for storing the frequency ID
    rsDummy = getDummy(projectNo);
    // creating SQL statement
    sqlStatement ="Select frequencyNo from tblRadio where radioNo = " + radioTemp;
    System.out.println(sqlStatement);
    // executing SQL statement
    rsTX = db.runQuery(sqlStatement);
    try {
    System.out.println("Test Marker EB1: 317");
    try {
    rsDummy.next();
    }     // end try
    catch     (java.sql.SQLException dummyException)     {
    System.out.println("dummyException" + dummyException);
    }     // end catch
    System.out.println("Test MarkerEB2: 330");
    // moving to first position in rs
    rsTX.next();
    System.out.println("Test MarkerEB3: 334");
    // obtaining data from rs
    freqNoTemp = rsTX.getInt(1);
    System.out.println("Test MarkerEB4: 337");
    rsTX.close();
    }     // end try
    catch (java.sql.SQLException rsTXException)     {
    System.out.println("rsTXExeption: " + rsTXException);
    }     // emd catch
    System.out.println("Frequency No is: " + freqNoTemp);
    rsDummy = getDummy(projectNo);
    sqlStatement = "Select frequency from tblFreq where frequencyNo = " + freqNoTemp;
    System.out.println(sqlStatement);
    rsRX = db.runQuery(sqlStatement);
    try {
    try {
    System.out.println("Test MarkerEB6: 361");
    rsDummy.next();
    }     // end try
    catch     (java.sql.SQLException dummyException)     {
    System.out.println("dummyException" + dummyException);
    }     // end catch
    System.out.println("Test MarkerEB5: 373");
    rsRX.next();
    System.out.println("Test MarkerEB7: 376");
    txTemp = rsRX.getDouble(1);
    System.out.println("Test MarkerEB8: 379");
    rsRX.close();
    }     // end try
    catch (java.sql.SQLException rxException) {
    System.out.println("rxException " + rxException);
    } // end catch
         System.out.println("393 Before return");
    return txTemp;
    }     //end getTX
    public int getConnection(int radio) {
    int nodeCon = 0;                    // Used to return the connected node no
    ResultSet rsConnection;          // Used for obtaining the foreign radio
    // creating SQL statement
    sqlStatement = "SELECT radioNo FROM tblRadio where recRadio = " + radio;
    System.out.println(sqlStatement);
    // executing SQL statement
    rsConnection = db.runQuery(sqlStatement);
    try {
    // moving to first position in rs
    rsConnection.next();
    // obtaining data from rs
    nodeCon = rsConnection.getInt(1);
    }     // end try
    catch (java.sql.SQLException getConnectionException) {
    System.out.println("getConnectionException : " + getConnectionException);
    }     // end catch
    // returns node no.
    return nodeCon;
    And finally, the dummy rs:
    // Dummy method to fix resultSet closed error
    public ResultSet getDummy (int projectNo) {
    sqlStatement = "Select projectName from tblProject where projectNo = " + projectNo;
    System.out.println(sqlStatement);
    rsDummy = db.runQuery(sqlStatement);
    return rsDummy;
    Here is some sample output that we have:
    ----jGRASP exec: java MainGui
    slider value constructor: 50
    116: if(singleton==null) {
    120: singleton=new Resolvotron
    Connection to D/Base establised
    Select projectName from tblProject where projectNo = 3
    Init OK. Beginning solve process
    main OK: beginning frequency assign process
    SELECT nodeNo from tblNode WHERE projectNo = 3
    267: Node number = 2
    SELECT * FROM tblRadio WHERE nodeNo =2
    EB Test Marker 1: Line 261
    Test Marker 1: Line 289
    298: Radio number = 4
    Test Marker 5: Line 308
    Test Marker 3: Line 313
    SELECT frequency from tblFreq WHERE projectNo = 3
    125.5
    Beginning test process
    Test Marker 4: Line 386
    Beginning check 257072
    Test Marker 6: Line 774
    70 Mhz Margin = false
    Beginning local 10Mhz separation check
    SELECT * FROM tblRadio WHERE nodeNo =2
    EB Test Marker 1: Line 261
    Getting TX of radio: 4
    Select projectName from tblProject where projectNo = 3
    Select frequencyNo from tblRadio where radioNo = 4
    Test Marker EB1: 317
    dummyExceptionjava.sql.SQLException: ResultSet is closed
    Test MarkerEB2: 330
    Test MarkerEB3: 334
    Test MarkerEB4: 337
    Frequency No is: 2
    Select projectName from tblProject where projectNo = 3
    Select frequency from tblFreq where frequencyNo = 2
    Test MarkerEB6: 361
    dummyExceptionjava.sql.SQLException: ResultSet is closed
    Test MarkerEB5: 373
    Test MarkerEB7: 376
    Test MarkerEB8: 379
    393 Before return
    432: getting connection
    SELECT radioNo FROM tblRadio where recRadio = 4
    438: getting TX of radio: 6
    Select projectName from tblProject where projectNo = 3
    Select frequencyNo from tblRadio where radioNo = 6
    Test Marker EB1: 317
    dummyExceptionjava.sql.SQLException: ResultSet is closed
    Test MarkerEB2: 330
    Test MarkerEB3: 334
    Test MarkerEB4: 337
    Frequency No is: 2
    Select projectName from tblProject where projectNo = 3
    Select frequency from tblFreq where frequencyNo = 2
    Test MarkerEB6: 361
    dummyExceptionjava.sql.SQLException: ResultSet is closed
    Test MarkerEB5: 373
    Test MarkerEB7: 376
    Test MarkerEB8: 379
    393 Before return
    java.sql.SQLException: ResultSet is closed
    10 Mhz Local = true
    Beginning 10 Mhz separation check
    SELECT nodeNo from tblNode WHERE projectNo = 3
    Node number is 2
    10 Mhz Global = false
    Beginning local harmonic resonance check
    SELECT * FROM tblRadio WHERE nodeNo =2
    EB Test Marker 1: Line 261
    Select projectName from tblProject where projectNo = 3
    Select frequencyNo from tblRadio where radioNo = 4
    Test Marker EB1: 317
    dummyExceptionjava.sql.SQLException: ResultSet is closed
    Test MarkerEB2: 330
    Test MarkerEB3: 334
    Test MarkerEB4: 337
    Frequency No is: 2
    Select projectName from tblProject where projectNo = 3
    Select frequency from tblFreq where frequencyNo = 2
    Test MarkerEB6: 361
    dummyExceptionjava.sql.SQLException: ResultSet is closed
    Test MarkerEB5: 373
    Test MarkerEB7: 376
    Test MarkerEB8: 379
    393 Before return
    SELECT radioNo FROM tblRadio where recRadio = 4
    Select projectName from tblProject where projectNo = 3
    Select frequencyNo from tblRadio where radioNo = 6
    Test Marker EB1: 317
    dummyExceptionjava.sql.SQLException: ResultSet is closed
    Test MarkerEB2: 330
    Test MarkerEB3: 334
    Test MarkerEB4: 337
    Frequency No is: 2
    Select projectName from tblProject where projectNo = 3
    Select frequency from tblFreq where frequencyNo = 2
    Test MarkerEB6: 361
    I'll leave it at that, since the program goes into an endless loop. The dummy Exceptions are our dummy resultsets crashing so the rest can survive. The other stuff is from different methods. You should be able to locate the logic of the program by following the System.outs
    Test Markers with EB refer to the Entry Broker.
    Any help would be appreciated since we cannot find any other way of running this class successfully.
    Steve

    Ok problem solved...
    Basically I was calling one ResultSet after another. Thanks to the Database Broker's structure, this was killing the first ResultSet. I fixed up the loops so that ResultSets were only ever called just before they were needed, and it fixed the problem. The only other errors were simple logic faults which I drummed out in short order. Thanks for the help everyone!

  • Search data into ResultSets to genrate a complex report

    Hi,
    I am writing a report called "Product Flow". The report headings are follows
    prodcode prod name opening qty purchase_qty sales_qty closing_qty
    =============================================================
    To achieve this, I need to know the products, their opening qty, their purchase qty, sales qty and finally I will I will calculate the closing stock.
    All this information is into different tables. I want to create 4-5 resultsets and then take the prodcut's resultset and scroll into it, take product one by one and then search its details into other resultset of opening, purchase and sales resultsets
    How can I do it with resultsets? can anyone guide me? I am very much new for Java.
    Thanks
    OMkar

    Dear,
    Evenif I use SQL join. While designing the report finally, do I not have to write some code to compare and search some data into various resultsets or some kind of collections?
    For example, in the above report, when I want to display report on screen, I will have to take the list of product and then search its values into tables and display it on the screen. So for this, do I not have to take the resultset of product table (rs) which will give me a list of product.
    use while (rs.next()) >
    take each product code
    search the values in other resultsets (to search these values in actual table may be time consuming becasue of huge size of table. If there are 500 products in the table, I will have to use the table for 500 times using SQL.
    Finally display the report on screen.How can I get more information about the collection type of resultset as u mentioned in the first reply? I will read the tutorials on SQL joins as you suggested and see if I can use it for this report.
    Thanks for the reply. I would high appreciate if you can guide me to achieve my aims of project I am doing my studies.
    Regards
    OMkar

  • Can we create multiple instances of a Bean in a JSP file?

    Hi,
    I am new to JSP & Servlets programming.
    I need to write a servlet that connects to a database via JDBC ( using IBM DB2 dbms) , sets some Beans with the tuples in the relevant table.
    Then, I need to have a JSP "read" ( or "get") info from the Beans & display the contents to the client.
    ( At a time only 5 tuples must be visible in the UI , with Next & Prev links ...)
    I am using Tomcat 4.0 for this...
    Can any one please help me regarding HOW to go abt it ?
    Esp., should we create 1 instance of a Bean , ( say "DataBean") for EACH tuple , or is there a way to do it with only 1 instance...
    Please, guide me... ( if not possible, at least give me some hints to some GOOD resources ( books, sites,etc.), that deal with this kind of applications)
    Thanks,
    Raghu.

    Once again, thanx a lot for your detailed help -- evnafets !!
    I think I am gaining in my knowledge of JSP & Servlets thanks to your help...
    Now, I am tackling the issue of selecting the BEST way of "STORING" which "PAGE" no. I am displaying.
    Say, I have only 15 tuples(ROWS), & with 5 tuples displayed per page, I have to have 3 "pages", & I need to accomplish the handling of "Prev" & "Next" links using only 1 Servlet & 1 JSP ( apart from the Authorization servlet ).
    I am thinking of storing a "session-scoped" variable called "page-num". Do you think it's the best way?
    Or should I score it as an "application-scoped variable" ( i.e., in the ServletContext ...) ??
    Also, I have got no clues as to which of the following would be a better idea :
    (a) Fetch ALL the tuples in the table & set as many beans. And then display the corresponding 5 tuples in each page.
    Here, more bean instances are needed to hold the data which gets repeatedly passed around ( when Prev & Next links are clicked ).
    OR ..
    (b)Fetch only 5 tuples at a time . I think this may be done by creating a scrollable Resultset & then moving around to the appropriate ROW by saying
    resultSet.absolute( (page_num - 1)*5 + 1 ); & then fetching 5 tuples relative to this row.
    In this case I will need atmost 5 Bean objects per request.
    And YES, one more thing , WOULD you PLEASE try & give me some guidance towards some good references to JSP, Servlets & J2EE ? ( Links, Books, anything ! )
    Sorry for the TROUBLE I gave, but THANKS a lot for the TROUBLE u took ! ;-)
    Thanks & Regards,
    Raghu

  • Bug in Oracle UpdatableResultSet? (insert, updateString requires non-empty ResultSet?

    As far as I can determine from the documentation and posts in other newsgroups
    the following example should work to produce an updatable but "empty" ResultSet which can be used to insert rows.
    But it doesn't work in a JDK 1.2.2 and JDK 1.3.0_01 application using Oracle 8i (8.1.7) thin JDBC
    driver against an Oracle 8.1.5 database I get the following error
    SQLException: java.sql.SQLException: Invalid argument(s) in call: setRowBufferAt
    However, if I change it to so the target (ie insert) ResultSet is initialized to contain one or more
    rows, it works just fine.
    ResultSet rset2 = stmt2.executeQuery ( "select Context.* from Context where ContextCd = '0' " );
    Is this a bug in Oracle's JDBC driver (more specifically, the UpdatableResultSet implimentation)?
    Does an updatabable ResultSet have to return rows to be valid and useable for insert operations?
    If it does, is there another way to create an updatable ResultSet that does not depend upon
    "hard-coding" some known data value into the query?
    try
    // conn is a working, tested connection to an Oracle database via 8.1.7 thin JDBC driver.
    // source statement
    Statement stmt = conn.createStatement (
    ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY );
    System.out.println("source rset");
    rset = stmt.executeQuery ( "select Context.* from Context" );
    // target Statement
    Statement stmt2 = conn.createStatement (
    ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE );
    ResultSet rset2 =
    stmt2.executeQuery ( "select Context.* from Context where ContextCd = NULL" );
    System.out.println(
    "see if rset2 looks good even though empty (bcs primarykey = null)");
    ResultSetMetaData rsmd2 = rset2.getMetaData();
    int numColumns = rsmd2.getColumnCount();
    for( int i = 0; i <= numColumns; i++ )
    env.msg.println ( "(" + i + ") " + rsmd2.getColumnLabel(i) );
    // test results showed the correct columns even though no row returned.
    // quess we can use this trick to create an "empty" insert ResultSet.
    System.out.println("interate through rset and insert using rset2");
    if(rset.next())
    System.out.println("move to insert row");
    rset2.moveToInsertRow();
    System.out.println("insert values");
    rset2.updateString( "ContextCd", rset.getString("ContextCd") + "-test" );
    rset2.updateString( "Descrip", "test" );
    rset2.updateString( "Notes", "test" );
    System.out.println("insert row into db (but not committed)");
    rset2.insertRow();
    catch( ... ) ...
    Thanks
    R.Parr
    Temporal Arts

    I have noticed the same problem, actually it doens't matter if there is no data in your resultset. If you have a result with data and suppose you were to analyze the data by moving through all of the rows, the cursor is now after the last row. If you call insertRow, the same exception is thrown. Kinda strange, I didn't get any response as to why this is happening and that was a few weeks ago. I hope someone responds, at this point I am just re-writing some of my code to not use updateable resultsets.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Randall Parr ([email protected]):
    As far as I can determine from the documentation and posts in other newsgroups
    the following example should work to produce an updatable but "empty" ResultSet which can be used to insert rows.
    But it doesn't work in a JDK 1.2.2 and JDK 1.3.0_01 application using Oracle 8i (8.1.7) thin JDBC
    driver against an Oracle 8.1.5 database I get the following error<HR></BLOCKQUOTE>
    null

  • Getting problem while MDM ResultSet iView

    Hi all,
    I am creating SAP MDM ResultSet iView.
    In
    Step 4: Search Table,
    I am not getting the Search table as pop-up even if the Test Connection with
    System Object of SAP MDM System object is successfull.
    All steps like creating System Object, System Alias and User Mapping is done correctly.
    Regards
    Neha Singh

    I just tried in my Env, just to check which step are you talking about, and surprisingly, i got the same error, the reason was my repository is not loaded right now.
    You may want to check that.
    Regards,
    Nitin
    Edited by: Nitin Mahajan on Dec 31, 2008 6:19 PM

  • MDM ResultSet iView

    Hi,
    In my page I have 2 iViews - an MDM ResultSet iView and  a web dynpro iView. In MDM ResultSet iView I have created a custom EPCF record event. The web dynpro application includes an iframe the source of which is another MDM ResultSet iview. The web dynpro subscribes to the above event. When the event occurs it receives some value, which it processes and then triggers the getRecordById event using the following URL
    "http://bwmumdev:50100/irj/servlet/prt/portal/prteventname/Navigate/prtroot/pcd!3aportal_content!2fevery_user!2fgeneral!2fdefaultDesktop!2fframeworkPages!2fframeworkpage!2fcom.sap.portal.innerpage!2fcom.sap.portal.contentarea?NavigationTarget=ROLES%3A%2F%2Fportal_content%2FSeema%2FMDM%2FNetrics%2FNetrics_Match_ResultSet&externalRequestEvent=com.sap.pct.mdm.appl.masteriviews.table.events.externals.GetRecordByIds&id=1&id=2
    Now, the problem is no matter how many ids are mentioned the iView displays only the first one...
    Please help me

    Please Ignore my previous message.
    My question is When we create a mdm resultset iview,it is asking to select either key mapping or resultset.
    but,I want to show in my iview with the following columns.
    Customer Client System Key.
    Here Customer is Customer value originally created.
    Client System and key values are added through edit key mapping feature.
    How to get noraml fields and key mappings in the same iview?

  • Getting the number of rows returned from ResultSet

    Hi,
    Does anyone know a method to get the number of rows returned with a query using the Resultset class?
    Thanks.

    Hi 281080,
    If your database and JDBC driver support it, in order to use the solution that da-alexj has suggested, you need to create a 'scrollable' "ResultSet" -- the javadoc for method "createStatement()" (in class "java.sql.Connection") has more details.
    However, I have found with Oracle 8.1.7.4 database and Oracle (thin) JDBC driver, that part of their implementation of the "last()" method (in class "java.sql.ResultSet") is to actually iterate through the entire "ResultSet" in order to reach the last row. If your "ResultSet" is very large (I tested it with a 100,000 row "ResultSet"), this will take a long time.
    Just wanted to make you aware of that.
    Of-course, this may be irrelevant to you since I didn't see any mention in your post of what database and JDBC driver you are using.
    Hope this has helped you, anyway.
    Good Luck,
    Avi.

  • Create/Edit button on Items Detail Iview very very slow

    Hi,
    I created a MDM resultset iview and MDM Item Details Iview for a very large table. When I click on the create or edit button on the Item Details iview, it keeps running and never finishes. This table has many fields and has many records but on the iview itself I am just displaying not more than 10 fields.
    When I created an item details iview for another small table, I can create and edit the records in no time. But for the above table, it takes for ever to Edit/Create.
    Can anybody tell me what the issue could be?
    Thanks
    MLS

    Hi Laxmi,
    The portal is just the front end replicating the processes of the backend system in your case the MDM system.
    Using the MDM repository with large number of records will cause a delay in creting or editing or even selcting records when operatings these functions from the MDM Data manger it self.
    In that case EP is just replicating this issue on the front end.
    As you have rightly mentioned that for smaller number of records in the MDM rep the function swork faster.It clearly indicates that even if you select less number of fields to be displayed on the front end,the backend still contains the large set of fields which needs to be processed,and this consume stime.
    To fasten your process on both the backend end and the front end systems you need to correctly design the data model and the fields properties which will improve the performance.
    You can refer the below link to better design your MDM data model:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/eb7447b1-0c01-0010-8d90-a2e004cad537
    Hope It Helped
    Thanks & Regards
    Simona Pinto

  • Blank MDM Resultset iView

    Hi,
    I created a MDM Resultset Iview in the portal. I selected the table and columns that are to be displayed. After creating the iview, when I see the preview, I am seeing the data in the resultset iview. I don't want the data to be seen. I need a blank resultset iview just with column names. How can we get this?

    Please Ignore my previous message.
    My question is When we create a mdm resultset iview,it is asking to select either key mapping or resultset.
    but,I want to show in my iview with the following columns.
    Customer Client System Key.
    Here Customer is Customer value originally created.
    Client System and key values are added through edit key mapping feature.
    How to get noraml fields and key mappings in the same iview?

  • MDM Resultset Iview (MDM 5.5 SP4)

    Hi All,
    I created MDM Resultset iview,in which I selected keymapping.but,when i see the preview,I am always getting No result found. but,I am having some records with key mappings.
    Thanks for your help.

    Please Ignore my previous message.
    My question is When we create a mdm resultset iview,it is asking to select either key mapping or resultset.
    but,I want to show in my iview with the following columns.
    Customer Client System Key.
    Here Customer is Customer value originally created.
    Client System and key values are added through edit key mapping feature.
    How to get noraml fields and key mappings in the same iview?

  • Setting default zoom level for creating bookmarks

    I am creating a PDF file in a couple of steps.  The main text is created from Word, which gives me bookmarks automatically set to "Inherit Zoom."  I also create subsets of tables and figures by "combining files in Acrobat" from Windows Explorer.  That step creates bookmarks automatically that are set to "Fit Width."  I then add the pages from the tables and figures into the PDF created from the Word document.  The bookmarks come in the proper location, but the zoom level stays "Fit Width."  I'd like it to be either "Inherit Zoom" or "Fit Page."  Is there a way to set the default zoom for bookmark creation so I don't have to manually change each bookmark?

    It seems like the DVT by default zooms to fit the available real estate. But is it possible to set a fixed zoom level (say 75%) even if the node does have 100% zoom level. We would like to show the 100% zoom level only on hover to the node. But by default, wanted to to set the viewer to always show 75% or 50% zoom level.

  • ResultSet.CONCUR_UPDATABLE

    I want to perform a query with the ResultSet.CONCUR_UPDATABLE option, because I want to delete some rows depending on some conditions.
    The problem is that I get no row in the result set, since the first next() invocation returns false.
    But when I perform the same query with just the same SQL sentence without the ResultSet.CONCUR_UPDATABLE option, I get the rows actually matching the WHERE condition.
    Any idea about what I am missing?
    Thanks in advance.

    Nothing at all.
    It has been defined in the CREATE statement as PTOVTA CHAR(20)
    What I can't understand is that the same SQL sentence behaves differently when the Statement instance is created with createStatement() (all columns are recognized without any problem) and when it is created with
    createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE) where it only works if I avoid to refer to that column in the sentence.

Maybe you are looking for

  • Issue changing the Logo on web UI

    Hello all, I have an issue where I can't get a new logo to show on our WEB UI skin. What i've done so far.. 1, I've created a BSP in se80, 2, spro > sap ref IMG > CRM > UI framework > UI framework definition > skins > Access Skin Workbench     Select

  • How can i restrict a variable to a subset of Values

    Hello, I've a variable say on Document type for a AP report, this document type  MD can have bunch of values.. but in the variable selection when they run the Query i've to restrict the selection to only to few document types. how can i do that? I tr

  • Extract tables from "Oracle Apss 11.0.3" and load it to "Oracle Apps 11i"

    Hi hussein, I am tasked to extract the following tables from Oracle Apps 11.0.3 and load it to Oracle Apps 11.5.10.2. PO_VENDORS PO_VENDOR_SITES_ALL Can I use export / import? Thanks a lot

  • Creating a Newsletter

    I have been tasked by my organization to create a monthly newsletter. I have just dowloaded iWork for that purpose, but it is clear that I need a crash course in "Pages." Where can I get the intruction I need?

  • In string comparisons

    Hello, I'm new to java and was wondering how I could do an in-string comparison. I.E. check if the string "the" is in "here is the". In ASP you can write inStr(string 1, string2) and I was wondering what the JSP equivalent was. any help is appreciate