Result Set help

Hello,
I encounter the following:
I created a sql Query and executed it, there were 2 cols to be feteched from the table for example col1, and col2.
After executing the query I write rs.next() so that I can access the first record of rs object. I then get the col2 from rs object first and then col1, this issues me an jdbc error, Invalid index error.
Here is the sample code:
ResultSet rs = stmt.executeQuery( sqlQuery);
if( rs.next() )
String strCol2 = rs.getString( "col2" );
String strCol1 = rs.getString( "col1" );
Does the order of getting the column from resultset matter?
Any help in this context is appreciated.
Regards.

According to the JDBC spec, out ot order fetching (what you are trying to do in your code sample) is an optional feature. So depending on the driver you are using, it might work or not.
If you don't depend on this feature, better don't use it. If you do, make sure you have a driver that supports it.
Alin.

Similar Messages

  • Using a Collection of beans to store a result set help.

    Does anyone have any sample code on the subject? This is something I wrote up, but I wanted feedback, and also an example of how to retreive data out of the array of beans in jsp
    package beanpersonal;
    import beandatabase.DBConnection;
    import java.sql.Connection;
    import java.sql.SQLException;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.sql.DataSource;
    import java.util.Collection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.util.ArrayList;
    public class PersonNew {
    public PersonNew() { }
    public Collection getPersondata( String alias, String password ) {
    Connection conn = null;
    PreparedStatement stmt = null;
    ResultSet rs = null;
    Collection retValue = new ArrayList();
    String query = "SELECT * FROM person WHERE (alias = ?, password = ?)";
    try {
    conn = DBConnection.getDBConnection();
    stmt = conn.prepareStatement( query );
    stmt.setString( 1, alias );
    stmt.setString( 2, password );
    rs = stmt.executeQuery();
    while (rs.next()) {
    PersonalInfo beanrow = new PersonalInfo();
    beanrow.setAlias(rs.getString("alias"));
    beanrow.setPassword(rs.getString("password"));
    retValue.add(beanrow);
    return retValue;
    catch( SQLException sqle ) {
    //sqle.printStackTrace();
    //throw new ApplicationSpecficException("Cannot query db", sqle);
    throw new RuntimeException(sqle);
    finally {
    try {if (rs != null) rs.close();} catch (SQLException e) {}
    try {if (stmt != null) stmt.close();} catch (SQLException e) {}
    try {if (conn != null) conn.close();} catch (SQLException e) {}
    }

    sorry i only view the codes, but don't read it as a whole maybe this codes can help you..
    jsp:
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@page import="java.util.*,mypackage.TestBean"%>
    <%
    String name = request.getParameter("name")!=null?request.getParameter("name"):"";
    String age = request.getParameter("age")!=null?request.getParameter("age"):"";
    System.out.println(name);
    System.out.println(age);
    Collection col = new ArrayList();
    col = (Collection)session.getAttribute("col")!=null?(Collection)session.getAttribute("col"):new ArrayList();
    TestBean tBean = new TestBean();
    if(!name.equals(""))
      tBean.setName(name);
    if(!age.equals(""))
      tBean.setAge(age);
    if(!age.equals("") || !name.equals(""))
      col.add(tBean);
    session.setAttribute("col",col);
    %>
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
        <title>untitled</title>
      </head>
      <body>
        <form>
          <table cellspacing="0" cellpadding="0" border="1" width="200">
            <tr>
              <td>Name</td>
              <td>
                <input type="text" name="name"/>
              </td>
            </tr>
            <tr>
              <td>Age</td>
              <td>
                <input type="text" name="age"/>
              </td>
            </tr>
            <tr>
              <td colspan="2">
                <input type="submit" value="Submit"/>
              </td>
            </tr>
          </table>
          <%
          if(col.size()>0){
          Iterator iter = col.iterator();
          %>
          <table cellspacing="0" cellpadding="0" border="1" width="200">
            <tr>
              <td>
                NAME
              </td>
              <td>
                AGE
              </td>
             </tr>
            <%while(iter.hasNext()){
              tBean = (TestBean)iter.next();
            %>
              <tr>
                <td>
                  <%=tBean.getName()%>
                </td>
                <td>
                  <%=tBean.getAge()%>
                </td>
               </tr>
            <%}%>
          </table>
          <%}%>
        </form>
      </body>
    </html>TestBean.java
    package mypackage;
    public class TestBean
      private String name;
      private String age;
      public TestBean()
      public String getName()
        return name;
      public void setName(String name)
        this.name = name;
      public String getAge()
        return age;
      public void setAge(String age)
        this.age = age;
    }

  • Need help in restricting a result set from a UNION in MERGE

    Hello,
    Would really appreciate if anybody could help me out with the issue I am facing with the below statements (I am new to Oracle ):
    merge into table_name_1 p
    using
      select p_key, value_1, value_2
      from some_tables
      UNION
      select p_key, value_1, value_2
      from some_tables
      UNION
    )t
    on (p.p_key = t.p_key)
    when matched then
      update table_name_1 with value_1 and value_2
    when not matched then
      insert table_name_1 with p_key, value_1, value_2;
    Now, the union of all those selects gives me distinct values and it works most of the times but when I get values like below, the merge fails:
    p_key-----value_1-----value_2
    100-----25-----50
    100-----NULL-----50
    I browsed the net and understood the reason behind this: the result set becomes ambiguous and merge doesn't know which row to insert first and which one to update.
    Now, my requirement is: I could have any of the below scenario/result sets from the union and I need only 1 row per p_key -
    result_set_1
    p_key-----value_1-----value_2
    100-----25-----50 ***************need this row
    100-----NULL-----50
    100-----NULL-----NULL
    result_set_2
    p_key-----value_1-----value_2
    100-----25-----NULL ***************need this row
    100-----NULL-----NULL
    result_set_3
    p_key-----value_1-----value_2
    100-----25-----NULL ***************need this row (p_key = 100)
    100-----NULL-----NULL
    200-----NULL-----75 ***************need this row (p_key = 200)
    200-----NULL-----NULL
    300-----90-----95 ***************need this row (p_key = 300)
    So, I basically need a way to restrict the values that I will get from the UNION of all those selects to fit the requirement above, hope I was able to explain the issue I am facing.
    Any help would be greatly appreciated.
    Thanks,
    Dpunk

    In all cases the goal is to find an order by value that will make the row you want be first.
    The query I gave is calculating a priority for each row by adding up values showing whether each column is null or not null. The case statements check whether each column is null and need to be added up to give a total priority value.
    Value_1   Value_2   Priority
    Not Null  Not Null  2 + 1 = 3
    Not Null  Null      2 + 0 = 2
    Null      Not Null  0 + 1 = 1
    Null      Null      0 + 0 = 0
    The priority value ends up being a bitmap showing whether each value is null or not null. I think that reflects my mathematics background.
    Another way of getting the same result (suggested to me by your asking why it needs the "+") would be to use two CASE expressions as separate order by items:
    select p_key, value_1, value_2 from
    (select p_key, value_1, value_2, row_number() over
              (partition by p_key
               order by case when value_1 is null then 0 else 1 end DESC,
                        case when value_2 is null then 0 else 1 end DESC
              ) as rn
      from (your UNION query here)
    where rn = 1
    A third way is to use a more complex case statement:
    select p_key, value_1, value_2 from
    (select p_key, value_1, value_2, row_number() over
              (partition by p_key
               order by case when value_1 is NOT null and value_2 is NOT null then 1
                             when value_1 is NOT null and value_2 is     null then 2
                             when value_1 is     null and value_2 is NOT null then 3
                             when value_1 is     null and value_2 is     null then 4
                         end  ASC
              ) as rn
      from (your UNION query here)
    where rn = 1

  • Please Help! ?Result Set not updating correctly

    Hi
    This problem has been driving me mad for days now so if anyone can shed any light on it I?d be really grateful.
    I have a jTable in a frame which is populated via a database. (NB I?m using Access 2000 and the JDBC-ODBC driver v.4.00.6019). Data is added to the table via a dialog box. i.e. when the submit button on the dialog box is clicked, the new data input into textfields and text areas in the dialog box is added to the database and then the database is requeried so that the data just added is also displayed in the table. The database is updated every time with no problems, I?m sure of this, however the jTable is not. Sometimes the jTable displays the updated data, other times it doesn?t. e.g. say I input ?a? via the dialog box, this value does not appear in the table. Then I input ?b? say, and ?a? will then be added to the table or sometimes ?a? and ?b? together. Sometimes the table is updated first time no problem, other times I have the scenario mentioned above.
    I?ve looked at the result set that?s being returned when the database is requeried and it contains exactly the same data that appears in the jTable. So despite the fact that the database is definitely updated, I?m getting an incorrect result set. I?m using only the one connection object that?s created when the application is begun. I?ve even tried a dummy select statement before my proper requery of the database (as I?ve seen mentioned for a similar problem) but this doesn?t solve the problem.
    I am ?refreshing? the jTable by way of a refresh method in the jTable?s Table Model.
    The code is:
    public void refresh ()
      rows.clear();
      firstColumn.clear();
      try {
       Statement statement = conn.createStatement();
       ResultSet rs = statement.executeQuery(query);
       ResultSetMetaData rsmd = rs.getMetaData();
       boolean moreRecords = rs.next();
         do
          rows.addElement( getNextRow (rs,rsmd));
         while (rs.next() );
         statement.close();
      catch ( SQLException sqlex )
        sqlex.printStackTrace();
      this.fireTableDataChanged();
    }//End of Method  And the actual refresh method is being called when the dialog box is closed:
    void jButton4_actionPerformed(ActionEvent e) {
        TimetableDialog tdBox = new TimetableDialog (this,"Enter Date and Event",true,dealName);
        setDialogBoxLocationCentre (tdBox);
        tdBox.setVisible(true);//Code below this not executed until Dialog disposed of
        boolean validData = tdBox.returnDataValid();
          timetableModel.refresh();
         Does anyone have any idea what might be going on? It is vital that I solve this. Thanks a lot for any help.
    LGS

    According to the documentation on the Connection class. New Connections are auto-commit by default, but the commit takes place irregularly.
    "The commit occurs when the statement completes or the next execute occurs." This maybe where the ambiguity occurs. Maybe try forcing the commit connection.commit();

  • Please help - Scrollable result set in sql server 2000

    Hi can some one please help me. I'm trying to create scrollable result set in sql server 2000, but i just can't get it to work. I've been trying to do this for the past 12 hours. I want to go home, but I can't till I get this going! please help!!! My crap code is as follows:
    package transact;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.JInternalFrame;
    import java.sql.*;
    import java.io.*;
    import java.util.*;
    public class DummyFrame extends Dummy
    protected String name, surname;
    protected Connection conn;
    protected CallableStatement cstatement;
    public DummyFrame()
    createFrame();
    private void createFrame()
    try
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    conn = DriverManager.getConnection(
    "jdbc:microsoft:sqlserver://server:1433;" +
    "user=user;password=pwd;DatabaseName=Northwind");
    catch (Exception e)
    e.getMessage();
    populateFields();
    menuAction();
    show();
    private void menuAction()
    btncontacts.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    getRecords();
    populateFields();
    btncontacts.setText("NEXT");
    btnkeywords.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent e)
    // transaction.getRecords();
    nextRecord();
    populateFields();
    btncontacts.setText("NEXT");
    protected void nextRecord()
    try
    // CallableStatement cstatement = null;
    cstatement = conn.prepareCall(
    "{call Employee_Selection}", ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    ResultSet rs = cstatement.executeQuery();
    while (rs.next())
    surname = rs.getString("Lastname");
    cstatement.getMoreResults();
    catch (Exception e)
    e.getMessage();
    protected void getRecords()
    try
    CallableStatement cstatement = null;
    cstatement = conn.prepareCall(
    "{call Employee_Selection}", ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_UPDATABLE);
    ResultSet rs = cstatement.executeQuery();
    while (rs.next())
    surname = rs.getString("Lastname");
    name = rs.getString("Firstname");
    rs.first();
    // call stored procedure
    catch (Exception e)
    e.getMessage();
    // populate the fields;
    private void populateFields()
    txtfirstname.setText(name);
    txtsurname.setText(surname);
    }

    ummm ok i think the logic in your code is kinda screwy...
    here is what your should be doing.
    create the gui.
    get the resultset...
    have code that looks like this for nextRecord...
    protected void displayNextRecord(){
      // we do not call next here because we already called it last time
      surname = rs.getString("Lastname");
      name = rs.getString("Firstname");
      populateFields();
      if(!rs.next(){
        btncontacts.setEnabled(false);// i'm not sure what btncontacts is but we want to disable next becuase there are no more records...
    // in your intitalization code you need to do this...
    // you old stuff ending with...
    ResultSet rs = cstatement.executeQuery();
    // the new stuff...
    if(rs.first()){
      displayNextRecord();
    }else{
      btncontacts.setEnabled(false);//the result set is empty
    }ok the real problem you are having is that you are trying to display one record at a time but you are scrolling
    through the entire result set using while(rs.next()... what you
    want to do is create the result set once and scroll through
    it one item at a time with your gui.
    the example method i have given displays the data from the current
    row in your gui. then it advances the result set forward one row if possible. this method assumes that the result set will always
    be positioned on a valid row thus the need for calling
    rs.first() before we originally call displayNextRecord()
    well i hope you find this helpful.

  • Please Help Urgent:Fast Search returning wrong result sets

    Hi All,
    We are facing below issue with fast search.
    Currently in My project  when  we are searching  for a phrase it is returning wrong result sets.
    For example if we search for “Endura”, It is returning documents related to
    Endura  as well as Centura.
    But the expected results are only Endura documents.
    When we look in to the documents we didn’t find the search term (“Endura” ) either inside document content or in its meta data.
    In order to resolve the issue we tried the below steps
    1-     
    We manually edited and saved the document, to ensure the appropriate Guid association to metadata.
    2-     
    Index reset
    3-     
    Full crawl
    But no luck  so far.
    Please help.Thanks in advance.
    Regards
    Subrat

    Subrat,
    This may be related to spellchecking or may be synonym. Spellcheck is based on indexed terms.
    The best test would be to run the queries from qrserver (13280) and then look at the spellcheck query transformations. If spellchecking is not doing it, then you must have a synonym setup .Check your keyword/synonyms from the SharePoint side. 

  • Need help in comparing values to display correct result set

    I have a View Object and Entity I created that point to a View on my database. This view contains a complex custom query that recovers and totals all charges and fees for all properties. However, when this result set is returned I only want to display on the initial screen the Row which contains the information for the current Property selected. However, in trying to implement this I am unsure how to:
    A) Somehow get the Property Id value of the Property currently in the JSP.
    B) Get the value of the Property Id column off each Row to compare to the value obtained in A.
    (I created an exact copy of the RowSetBrowser bean named SRIRowSetBrowser and am trying to add code to control which Rows get sent off to be added to the HTML Table)
    I can not find any documentation or source for the Row class and thus have no way to know if any methods are provided that would help me.
    Any ideas?
    Thanks

    Thats a mistake while modifying the XML.
    The Element is OpenOrder:
    so the XML goes like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <BOOK_PURCHASE_SR xsi:schemaLocation="http://www.mobily.com/blackberry/request request.xsd"
    xmlns="http://www.mobily.com/blackberry/request"
    xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance">
    <SR_HEADER>
    <Name>Java</Name>
    <Book>0000</Book>
    <Price>100</Price>
    <Purchase>Y</Purchase>
    <PurchaseDate>20070902153930</PurchaseDate>
    <Requestorname>Rashmi</Requestorname>
    <RequestorLanguage>E</RequestorLanguage>
    <OpenOrder>N</OpenOrder>
    <Chargeable>Y</Chargeable>
    <ChargeAmount>99</ChargeAmount>
    </SR_HEADER>
    <PhoneNumber>1234567890</PhoneNumber>
    <Service>shop</Service>
    <Operation>purchase</Operation>
    <CustomerType>2</CustomerType>
    </BOOK_PURCHASE_SR>

  • SQL query with parameter returns empty result set, please help !!!

    Hi there,
    When I use the following query :
    <sql:query var="beroepsthemas" >
    select *
    from beroepsthemas
    where beroepsthemaid = ?
    <sql:param value="12"/>
    </sql:query>
    When I want to browse the result set with :
    <c:forEach items="${beroepsthemas.rows}" var="rij">
    it shows no records. But it must return at least one.
    All my jsp pages with sql queries and parameters have the same problem.
    This is all on my test environment. I'm using Ubuntu 5.10, Netbeans5.0, JDK 1.5_06, application runs in Bundeled Tomcat 5.5.9, MySQL 4.1.12, mysql-connector3.1.6
    When the same code is run on the live environment, it works just fine.
    The difference is :
    Mysql 4.1.10a, tomcat5.5.9, mysql-connector3.1.6
    What can there be wrong !!

    When the same code is run on the live environment, it
    works just fine.
    The difference is :
    Mysql 4.1.10a, tomcat5.5.9, mysql-connector3.1.6
    I didn't catch this. I think you may need to update the database driver.

  • Help with streaming result sets and prepared statements

    hi all
    I create a callable statement that is capable of streaming.
    statement = myConn2.prepareCall("{call graphProc(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}",java.sql.ResultSet.TYPE_FORWARD_ONLY,
    java.sql.ResultSet.CONCUR_READ_ONLY);
    statementOne.setFetchSize(Integer.MIN_VALUE);
    the class that contains the query is instantiated 6 times the first class streams the results beautifully and then when the second
    rs = DatabaseConnect.statementOne.executeQuery();
    is executed I get the following error
    java.sql.SQLException: Can not use streaming results with multiple result statements
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910)
    at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:1370)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1688)
    at com.mysql.jdbc.Connection.execSQL(Connection.java:3031)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:943)
    at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1049)
    at com.mysql.jdbc.CallableStatement.executeQuery(CallableStatement.java:589)
    the 6 instances are not threaded and the result set is closed before the next query executes is there a solution to this problem it would be greatly appreciated
    thanks a lot
    Brian

    Database resources should have the narrowed scope
    possible. I don't think it's a good idea to use a
    ResultSet in a UI to generate a graph. Load the data
    into an object or data structure inside the method
    that's doing the query and close the ResultSet in a
    finally block. Use the data structure to generate
    the graph.
    It's an example of MVC and layering.
    Ok that is my bad for not elaborating on the finer points sorry, the results are not directly streamed into the graphs from the result set. and are processed in another object and then plotted from there.
    with regards to your statement in the beginning I would like to ask if you think it at least a viable option to create six connections. with that said would you be able to give estimated users using the six connections under full usage.
    just a few thoughts that I want to
    bounce off you if you don't mind. Closing the
    statement would defeat the object of of having a
    callable statement How so? I don't agree with that.
    %again I apologise I assumed that since callable statements inherit from prepared statements that they would have the pre compiled sql statement functionality of prepared statements,well If you consider in the example I'm about to give maybe you will see my point at least with regards to this.
    The statement that I create uses a connection and is created statically at the start of the program, every time I make a call the same statement and thus connection is used, creating a new connection each time takes up time and resources. and as you know every second counts
    thanks for your thoughts
    Brian.

  • Looping through 2 Result Sets - Not working-HELP!!

    This code loops through my first result set fine.....so I take the first part number from the result set, do a second result set to bring back all part conditions associated with that part number and compare them to see if they are all the same. When it hits the second loop with the second result set, it only loops once. I know this because of my system.out.println only print once.....can someone see where I'm going wrong....thanks in advance....
    public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
    DataSource ds = this.getDataSource();
    HttpSession sess = req.getSession();
    if (sess == null)
    res.sendRedirect(/error.html");
    else
    synchronized(sess)
    UtilParts part = (UtilParts)sess.getValue("UtilParts.PARTS");
    String[] partNumbers = new String[10];
    for(int index=0; index < partNumbers.length; index ++)
    partNumbers[index] = req.getParameterValues("partNumber"+index)[0];
    partNumbers[index] = partNumbers[index].trim();
    String partDesc = req.getParameterValues("partdesc")[0].toUpperCase();
    partDesc = partDesc.trim();
    int rowsCounted = 0;
    for(int index = 0 ; index < partNumbers.length; index ++)
    if(partNumbers[index].equals(""))
    rowsCounted ++;
    Connection conn = null;
    ResultSet resultSet = null;
    ResultSet resultSetMultCond = null;
    PreparedStatement getPartInfo = null;
    Statement getMultPartCond = null;
    String sqlMultCond = null;
    String sql = null;
    try
    conn = ds.getConnection(id,pass);
    conn.setReadOnly(true);
    if(partDesc.equals(""))
    sql = "SELECT #PART,#PDESC,#CONDS,COUNT(#PART) AS PCOUNT FROM MYLIB WHERE #PART LIKE '";
    boolean first = true;
    for (int i=0; i < partNumbers.length; i++)
    if (!partNumbers.equals(""))
    if (!first)
    sql += "%' OR #PART LIKE '";
    sql += partNumbers;
    first = false;
    sql += "%' AND #RECDT BETWEEN 20010816 AND 20020816 GROUP BY #PART,#PDESC,#CONDS ORDER BY #PART";
    getPartInfo=conn.prepareStatement(sql);
    resultSet = getPartInfo.executeQuery();
    if(!partDesc.equals(""))
    String sqlDesc = "SELECT #PART,#PDESC,#CONDS,COUNT(#PART) AS PCOUNT FROM MYLIB WHERE #PDESC LIKE ? AND #RECDT BETWEEN 20010816 AND 20020816 GROUP BY #PART,#PDESC ORDER BY #PART";
    getPartInfo = conn.prepareStatement(sqlDesc);
    getPartInfo.setString(1,partDesc + "%");
    resultSet = getPartInfo.executeQuery();
    Vector enum = new Vector();
    int rowsadded = 0;
    while (resultSet.next())
    rowsadded += 1;
    UtilParts utilityPart = new UtilParts();
    String s = (String)resultSet.getString("#PART");
    s = s.trim();
    utilityPart.setPartNumber(s);
    String t = (String)resultSet.getString("#PDESC");
    t = t.trim();
    utilityPart.setPartDesc(t);
    int resultCount = 0;
    int sameCond = 0;
    String storeName = null;
    String holdName = "No";
    int i = resultSet.getInt("PCOUNT");
    String cond;
    if(i == 1)
    String c = (String)resultSet.getString("#CONDS");
    c = c.trim();
    if(c.equals(""))
    cond = "N/A";
    else
    cond = c;
    utilityPart.setPartCondition(cond);
    utilityPart.setPartCount(i);
    else
    sqlMultCond = "SELECT #PART,#CONDS,COUNT(*) AS MCOUNT FROM MYLIB WHERE #PART = '" + s + "' AND #RECDT BETWEEN 20010816 AND 20020816 GROUP BY #PART,#CONDS ORDER BY #PART";
    getMultPartCond = conn.createStatement(java.sql.ResultSet.TYPE_SCROLL_SENSITIVE,java.sql.ResultSet.CONCUR_UPDATABLE);
    resultSetMultCond = getMultPartCond.executeQuery(sqlMultCond);
    int row =0;
    while(resultSetMultCond.next())
    row += 1;
    System.out.println("Row: " + row);
    resultCount = resultSetMultCond.getInt("MCOUNT");
    System.out.println("MCount: " + resultCount);
    if(holdName.equals("No"))
    System.out.println("You are in the no loop");
    storeName = (String)resultSetMultCond.getString("#CONDS");
    holdName = storeName;
    sameCond += 1;
    System.out.println("Same condition: " + sameCond);
    System.out.println("StoreName: " + storeName);
    System.out.println("HoldName: " + holdName);
    else
    storeName = (String)resultSetMultCond.getString("#CONDS");
    if(holdName.equals(storeName))
    sameCond += 1;
    System.out.println("Same condition: " + sameCond);
    System.out.println("StoreName: " + storeName);
    System.out.println("HoldName: " + holdName);
    resultSetMultCond.close();
    getMultPartCond.close();
    if(resultCount == sameCond)
    System.out.println("resultcount equals samecount");
    utilityPart.setPartCount(1);
    utilityPart.setPartCondition("same conditions everywhree");
    else
    System.out.println("resultcount not equal samecount");
    utilityPart.setPartCount(i);
    utilityPart.setPartCondition("");
    enum.addElement(utilityPart);
    }//end of first while
    if (rowsadded == 0 )
    res.sendRedirect("/PartNotFound.html");
    sess.putValue("PARTS",enum);
    resultSet.close();
    conn.close();
    getServletConfig().getServletContext().getRequestDispatcher("/NextQuery.jsp").forward(req,res);
    return;
    catch (SQLException e1)
    System.out.println(e1.getMessage());
    e1.printStackTrace();
    res.sendRedirect("/FindPartSQLError.htm");
    }//end of synchronized session
    }//end of else
    }//end of method

    Got the answer...changed my select statement in my second loop, did a group by CONDS which of course if they are all the same....the result set would only have one value therefore the loop will only execute once...took out the group by CONDS and ran fine....

  • SQL Exception: Result Set Closed. Help Needed Pls...

    Hi
    I am trying to insert the name field into �TestNoName� table which is randomly retrieved from �UniqueName� table. I am getting SQL exception: result set closed. Please look at the given code and let me know what�s wrong with my code:
    Also please guide me about entering unique (serial numbers) dynamically into
    database using Java. I have to enter customer details into database at some time and some customers details after some time but the customers should be given serial numbers.
    Thank you in advance!
    Ravi
    Here is the Code:
    String query1 = "Select Name from Unique_Names";
    String query2 = "SELECT Number, Name FROM TestNoName";
    Statement stmt;
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    } catch(java.lang.ClassNotFoundException e) {
    System.err.print("ClassNotFoundException: ");
    System.err.println(e.getMessage());
    try {
    con = DriverManager.getConnection(url,"","");
    System.out.println("Successfully Connected to Database");
    stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
    ResultSet rs = stmt.executeQuery(query1);
    ResultSet rs2 = stmt.executeQuery(query2);
    int count=0;
    while (rs.next()) {
    count++;
    rs.beforeFirst();
    for(int i = 0; i < 10; i++) {
    int randomrow = random.nextInt(count)+ 1;
    System.out.println(randomrow);
    String Name2 = rs.getString("Name");
    rs2.moveToInsertRow();
    rs2.updateInt("Number",i);
    rs2.updateString("Name",Name2);
    rs2.insertRow();
    System.out.println("Exececuted SQL Statement- Inserted One Record");
    stmt.close();
    con.close();
    } catch(SQLException ex) {
    System.err.println("SQLException: " + ex.getMessage());
    }

    I am trying to insert the name field into
    �TestNoName� table which is randomly retrieved from
    �UniqueName� table. I am getting SQL exception:
    result set closed. Please look at the given code and
    let me know what�s wrong with my code: Post the actual exception, not some paraphrase of it. Oh, and let us know which line it actually refers to in the code.

  • BW Web Report Issue - Result set too large

    Hi,
    When I execute a BEx Query on Web I am getting “Result set too large ; data retrieval restricted by configuration (maximum = 500000 cells)”.
    Following to my search in SDN I understood we can remove this restriction either across the BW system globally or for a specific query at WAD template.
    In my 7x Web template I am trying to increase default max no of rows parameters, As per the below inputs from SAP Note: 1127156.
    But I can’t find parameter “Size Restriction for Result Sets” for any of the web items (Analysis/Web Template properties/Data Provider properties)….in the WAD Web template
    Please advise where/how can I locate the properites
    Instructions provided in SAP Note…
    The following steps describe how to change the "safety belt" for Query Views:
    1. Use the context menu Properties / Data Provider in a BEx Web Application to maintain the "safety belt" for a Query View.
    2. Choose the register "Size Restriction for Result Sets".
    3. Choose an entry from the dropdown box to specify the maximum number of cells for the result set.
                  The following values are available:
    o Maximum Number
    o Default Number
    o Custom-Defined Number
                  Behind "Maximum Number" and "Default Number" you can find the current numbers defined in the customizing table RSADMIN (see below).
    4. Save the Query View and use it in another Web Template.
    Thanks in advance

    Hi Yasemin,
    Thanks for all help...i was off couple of days.
    To activate it I can suggest to create a dummy template, add your query in it, add a menu bar component add an action to save the query view. Then you run the template and change the size restriction for result set then you can save it by the menu.
    Can you please elaborate on the solution provided,I created dummy template with analysis and Menu bar item...i couldn't able to configure menu bar item...
    Thanks in advance

  • How can I use ONE Text search iView to event/affect mutliple Result Sets?

    hello everyone,
    i have a special situation in which i have 6 flat tables in my repository which all have a common field called Location ID (which is a lookup flat to the Locations table).
    i am trying to build a page with a free-form text search iView on Table #1 (search field = Location ID).  when I execute the search, the result set for Table #1 is properly updated, but how do I also get Result Set iViews for Tables #2-6 to also react to the event from Text Search for Table #1 so that they are updated?
    i don't want to have to build 6 different text search iViews (one for each table).  i just want to use ONE text search iView for all the different result set tables.  but, in the documentation and iView properties, the text search iView doesn't have any eventing.
    if you have any suggestions, please help.
    many thanks in advance,
    mm

    hello Donna,
    that should not be a problem, since you are detailw with result sets and detail iviews because custom eventing can be defined for those iviews.
    Yes, it says "no records" found because an active search and record selection havent' been performed for it (only your main table does).
    So, yes, define a custom event, and pass the appropriate parameters and you should be fine.
    Creating a custom event between a Result Set iView and an Item Details iView is easy and works. I have done it.
    See page 35 of the Portal Content Development Guide for a step-by-step example, which is what I used.
    For my particular situation, the problem I'm having is that I want the Search Text iView's event (i.e., when the Submit button is pressed) to be published to multiple iViews, all with different tables.  Those tables all share some common fields, which is what the Search iView has, so I'd like to pass the search critera to all of the iViews.
    -mm

  • Query Error Information: Result set is too large; data retrieval ......

    Hi Experts,
    I got one problem with my query information. when Im executing my report and drill my info in my navigation panel, Instead of a table with values the message "Result set is too large; data retrieval restricted by configuration" appears. I already applied "Note 1127156 - Safety belt: Result set is too large". I imported Support Package 13 for SAP NetWeaver 7. 0 BI Java (BIIBC13_0.SCA / BIBASES13_0.SCA / BIWEBAPP13_0.SCA) and executed the program SAP_RSADMIN_MAINTAIN (in transaction SE38), with the object and the value like Note 1127156 says... but the problem still appears....
    what Should I be missing ??????  How can I fix this issue ????
    Thank you very much for helping me out..... (Any help would be rewarded)
    David Corté

    You may ask your basis guy to increase ESM buffer (rsdb/esm/buffersize_kb). Did you check the systems memory?
    Did you try to check the error dump using ST22 - Runtime error analysis?
    Edited by: ashok saha on Feb 27, 2008 10:27 PM

  • SAP Note: 1127156 Result set is too large

    Hi,
    The note 1127156 explains how to resolve the issue with removing the message "Result Set is too large." I want to check the settings in the template and it gives the following steps but i cannot find the settings on the Analysis web item of the data provider.
    Can someone pls help.
    Query View
    The following steps describe how to change the "safety belt" for Query Views:
    1. Use the context menu Properties / Data Provider in a BEx Web Application to maintain the "safety belt" for a Query View.
    2. Choose the register "Size Restriction for Result Sets".
    3. Choose an entry from the dropdown box to specify the maximum number of cells for the result set.
                   The following values are available:
         Maximum Number
         Default Number
         Custom-Defined Number
                   Behind "Maximum Number" and "Default Number" you can find the current numbers defined in the customizing table RSADMIN (see below).
    4. Save the Query View and use it in another Web Template.
    Many thanks

    Hi,
    I was facing the same issue in BEx analyzer 7.0. The query was working fine in BW 3.5 analyzer but gave error in BEx 7.0.
    When executed in web, it gave error result set is too large.
    The maximum no of cells that can be displayed is 750000.
    Please check the result set returned by the query. Also check note Note 1040454 - Front-end memory requirement of the BEx Analyzer.
    Some enhancement are planned to be delivered in enhancement package 1.
    Regards,
      Niraj

Maybe you are looking for