Want to retrieve first row from recordset

hi,
I am trying to retrieve a value from frist row , second cloumn.
from recordset and it is an integer value, but when I try to do that, it is throwing an error.
java.sql.SQLException: Result set type is TYPE_FORWARD_ONLY
at sun.jdbc.odbc.JdbcOdbcResultSet.first(Unknown Source)
at TicketClientRetriever.TicketNumberGenerator.checkLastTicket(TicketNum
berGenerator.java:35)
at TicketClientRetriever.TicketCreator$3.actionPerformed(TicketCreator.j
ava:204)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Sour
ce)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
please check the part of the code Below which is used to retrieve the data
public static int checkLastTicket()
          //int i =0;
          connection1();
          try
               Ex1rs = Ex1Stmt.executeQuery("Select * from Ticketlog Order By TicketNumber DESC");
               if (Ex1rs!=null)
                     Ex1rs.isFirst();     
                     ticket = Ex1rs.getInt(2);
                     System.out.println(ticket);
               else
                    System.out.println("Recordset is empty");
          catch (Exception e)
               e.printStackTrace();
          System.out.println(ticket);
     return ticket;
          

A JDBC tutorial would really help you out. You can find one at:
http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/JDBC20.html
If your too busy (or lazy) to take the tutorial, this might get you going:
A ResultSet is initially positioned BEFORE the first row. You need to move to the first row most commonly done using rs.next()
rs.isFirst() returns a boolean that is true IF you are on the first row. You don't seem to be using it that way...
Good Luck!

Similar Messages

  • How  to retrieve one row from the number of records in a table

    i want to retrieve the rows from the number of records in a table without using the perticular column name.

    select count(*) from table
    /If you have your table currently analyzed, and no changes have been made, then you could
    select num_rows from user_tables where table_name = 'table'

  • How to get first row from View Object cache.

    hi,
    I am using Jdeveloper 11.1.1.6
    can we get first row from View Object cache??
    Thanks in Advance.
    Best
    Shashidhar

    Hi Frank,
    Thanks for reply!!
    My case is:
    I have a Query based ViewObject.
    One of the field is LOV and remaining fields are in ADF table. the LOV field is out side ADF table when i insert first record in ADF table and i choose LOV  filed the value is selected.
    when i create second row LOV value got refreshed because both are in same VO.
    I need to get the LOV value of first row and set same value to second Row.
    Shashidhar

  • Want to retrieve Account information from Siebel on demand thru web service

    Hi
    i have trial account on 'Siebel on demand' and want to retrieve the information from account or any object. There is one method mentioned in the 'OnDemWebSvcs.pdf' file as 'ContactQueryPage' ,but how to used this method is not clear.
    So can any body give any pointer on this?
    Thanks
    Yash

    Hi,
    Thanks for immd reply and it is really useful for new user like me.
    I converted the wsdl file to java. Now suppose i want to fetch all the record from User object on SOD, i wrote the following code snippet but got error as Internal Error: Session is not available. Aborting Server.
    Code : In java
    private static String mstrUrl="https://secure-ausomxega.crmondemand.com/Services/Integration";
    URL wsUrl = new URL(mstrUrl);
    Default_BindingStub defaultBindingStubObject=new Default_BindingStub(wsUrl,null);
    UserLocator []listOfUser=new UserLocator[1];
    UserLocator userLocatorObject=new UserLocator();
    //String xml ="<ListOfUser><User><FirstName /><UserLastName /><LastUpdated> (>='07/28/2004 06:30:00') AND (<='07/28/2009 06:45:00')</LastUpdated></User></ListOfUser>"
    UserWS_UserQueryPage_Input("1","1",listOfUser1,"1");
    UserWS_UserQueryPage_Input userWS_UserQueryPage_InputObject=new UserWS_UserQueryPage_Input("1","1",listOfUser,"1");
    UserWS_UserQueryPage_Output userWS_UserQueryPage_OutputObject = defaultBindingStubObject.userQueryPage(userWS_UserQueryPage_InputObject);
    Can any body provide any pointer on this, how to make a query in Siebel On Demand.
    Thanks
    Yash

  • FWD: Re: Retrieving multiple rows from a database into morethan

    There are two ways to do this that I cn think of right off the bat.
    One is to create a class of objects that can receive the entire row, and
    give it methods that will return each of the individual objects that you are
    looking for when called. If you use INTO :ARRAY, you get the advantage of
    being able to pass the array anywhere in your system for the 'split up'
    processing.
    Two is to do basically the same thing, but instead doing the 'split up'
    during a for loop. This will appear to slow down your query, however, as
    extra processing will be occuring in terms of memory allocation and copying.
    I'm sure there other approaches. This was simply what came to mind at
    midnight, after a long day :-).
    At 01:33 AM 6/4/96 +0000, you wrote:
    Does anyone know of a way to retrieve multiple rows from a single table in an
    RDB database into more than 1 object, using a single SQL call?
    I have a single table that I wish to use some fields to populate one object
    and some others to populate another.
    The FOR clause only allows one object to be specified.
    The INTO :ARRAY clause also seems to only allow one object to be specified.
    I would appreciate any help.
    Regads,
    Steve Isaac
    Hydro Electric Commission
    Hobart TAS 7001
    Australia
    [email protected]
    James Urquhart Voice: (510)869-3400
    [email protected] Fax: (612)921-8243
    Forte Consulting

    wow, that was pleasant, the usual format goes:
    Newb: I have a problem, fix it for me
    Forum: Here's a link explaning the concept you obviously don't grasp
    Newb: No, fix it FOR me
    Forum: I'll fix you!
    Newb: WAAAAH!
    Forum: BAN!

  • Newbie wants to remove first name from cell that contains "FIRST LAST"

    Any help is appreciated, I'm pretty much a complete newb with a spreadsheet. I have a sheet with sales prospects. One cell has the the full name in a cell, i.e. "John H. Doe". Some of the cells have a period after the middle initial. Some cells have no middle initial. What I am wanting to do is to create a new cell that only contains the first name. If it makes it any easier, I do have another cell that contains only the last name. When explaining how to do this, I ask that you dumb it down for me! I have about 850 rows. I'll need instructions completely in steps. I don't know how to apply a function to a new column. Thanks in advance! I know I'm asking alot.
    Message was edited by: Blacktop711

    BT,
    It would help you to get acquainted with Numbers if you read the User Guide PDF. It's written at a beginner level, not like a reference manual.
    This solution assumes that the full name is in column A. If not, you can substitute your true column for the "A"s in the formula. Click the label on Column A to select it. In the Table Menu, select Add Column After, to make a blank column to the right of the full name column. Let's assume that your first row is a Header Row, so you won't have data or equations in the first row. In the second row of the new column, paste this expression: =IFERROR(LEFT(A, FIND (" ", A)-1), "") (Copied from here)
    That cell that you pasted the expression into should now show the first name of the person in row 2. Now select that row 2 cell and Shift-Click the last cell in that column so that all the cells from row 2 down are selected. Next select Insert > Fill > Fill Down.
    Now all your first names should be showing.
    Let us know if you have any trouble with this.
    Jerry

  • Retrieve one row from multiple similar values column

    So, i have Following table records with repeated name with different emails -
    EmailDirc
    EmailID
    Ename
    Edob
    [email protected]
    Harish Salve
    15-10-1989
    [email protected]
    Navin Keddy
    17-02-1987
    [email protected]
    Harish Salve
    15-10-1989
    [email protected]
    Navin Keddy
    17-02-1987
    [email protected]
    Harish Salve
    15-10-1989
    [email protected]
    Harish Salve
    15-10-1989
    and now i want to retrieve rows on behalf of Ename like following -
    EmailDirc
    EmailID
    Ename
    Edob
    [email protected]
    Harish Salve
    15-10-1989
    [email protected]
    Navin Keddy
    17-02-1987
    kindly put some light to accomplish below required goal, thanks in advance.

    Try the below:
    Create Table EmailDir(emailid varchar(50),Ename varchar(100), Edob date)
    Insert into EmailDir Values('[email protected]','Harish Salve','10-15-1989'),
    ('[email protected]','Navin Keddy','02-17-1987'),
    ('[email protected]','Harish Salve','10-15-1989')
    ;With cte as
    Select EmailID,EName,Edob,Row_Number()Over(partition by EName Order by EmailID asc) Rn
    From EmailDir
    ) Select * From cte where rn=1
    Drop table EmailDir

  • Exact fetch returns more than requested number: Retrieve first row

    I have this statement:
    FOR l IN C1 LOOP
    select amount,customer_id   INTO F_AMT,I_custid from zerorize where doc_id = l.doc_id and trans_type = C_py;
    END LOOP;I hit the this error:
    ORA-01422: exact fetch returns more than requested number of rows
    ORA-06512: at line 172I will like to amend my sql statement in such a way it will retrieve the first row. How am I suppose to add my where condition clause?

    gerd_99 wrote:
    BluShadow wrote:
    If you don't have a means of restricting your query to only return 1 row based on data you would have to use the row number...
    e.g.
    select data, data2, .....
    from (
    select data, data2, ....., rownum rn
    from table
    where rn = 1
    In this case you even don´t need the inline view:I know, but if an "order by" is included in the inline view then it's necessary as rownum is assigned before the ordering is done, hence it is always safer to do it this way. ;)

  • How to get first row from view iterator programatically?

    Hi All,
    I am using Jdeveloper 11g Release 2.
    I want to fetch the first row of a view iterator in a bean. Can any one guide me through this use case.
    Any help will be highly appreciated.
    Thanks ... Best Regards
    Bilal

    Use the code snippet as below:
    *// 1. Access the binding container*
    DCBindingContainer bc = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    *// 2. Find a named iterator binding*
    DCIteratorBinding iter = (DCIteratorBinding)bc.findIteratorBinding("<ITERATOR_NAME>");
    *//3. Get the RowSetIterator Object*
    RowSetIterator rsi = iter.getRowSetIterator();
    *//4. Get the First Row*
    Row firstRow = rsi.first();
    Thanks,
    Navaneeth

  • First row from Service Order Object list not stored in OBJK table

    Hi all,
    Please be patience with my terminology .
    Could you please explain me if we have SO created based on notification, and that notification already have Equipment number, why this equipment is not created in OBJK table? So always the first row (as in attachment) is not stored in OBJK, other rows(objects) are there.
    I know the EQUNR is stored in AFIH, but it's useless for us because I'm creating HANA analytical view with following join logic (simplified):
    AFIH.OBKNR=OBJK.OBKNR
    OBJK.ILOAN=ILOA.ILOAN
    ILOA.TPLNR=IFLOT.TPLNR
    ILOA.ILOAN=EQUZ.ILOAN (where EQUZ.DATBI='99991231')
    EQUZ.EQUNR=EQUI.EQUNR
    The join logic might not be 100% correct.
    Thank you for your help.

    Using the tags to format your code may help you get a response sooner than later.
    This and other useful pieces of information are located in the  FAQ
    http://wiki.oracle.com/page/Oracle+Discussion+Forums+FAQ                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • I am wanting to exactly match two ID numbers from two differing worksheets within one work book. Once matched I am wanting to retrieve a row value from the second worksheet into the first. Any help much appreciated.

    I am wanting to exactly match two ID numbers from two worksheets within the one work book. ID numbers are non linear. Once exactly matched I wish to retrieve a corresponding row value from worksheet two and have it appear in worksheet one against the correct ID number. I have been looking at IF, VLOOKUP, and MATCH functions and suspect that what I want to do requires a combination of two or more. Any help will be greatly appreciated.
    regards Vaughanh

    Vaughan,
    Data A:D is all cells start at column A thru column D.
    There is built-in help using the menu item "View > Show Function Browser"  in the search field (top right) you can enter vlookup and you will see the detailed description.
    From this we see:
    VLOOKUP
    (search-for, columns-range, return-column, close-match)
    search-for:  The value to find. search-value can contain any value type.
    columns-range:  A range of cells. range is a reference to a single range of cells, which may contain values of any type.
    return-column:  A number that specifies the relative column number of the cell from which to return the value. return-column is a number value. The leftmost column in the range is column 1.
    close-match:  An optional value that determines whether an exact match is required.
    close match (TRUE, 1, or omitted):  If there’s no exact match, select the column with the largest top-row value that is less than the search value. Wildcards can’t be used in search-for.
    exact match (FALSE or 0):  If there’s no exact match, return an error. Wildcards can be used in search-for.
    So... the 2,0 means return the value form the same row as the lookup value but from the 2nd column of the range.  3, 0 means from the 3rd column.  the ", 0" means exact match

  • Select first row from every set

    id num dtl sdate udate
    4 4JQ010907 MO601159736142323333 09-NOV-03
    4 4JQ010907 MO601159736142323333 09-NOV-03 08-DEC-03
    4 4JQ010907 MO601159736142323333 09-NOV-03 08-NOV-04
    4 4JQ010907 MO601159736142323333 09-NOV-03 09-DEC-03
    4 4JQ014529 W436-5902-285308-17-00 30-JAN-04
    4 4JQ014529 W436-5902-285308-17-00 30-JAN-04 02-FEB-04
    4 4JQ014529 W436-5902-285308-17-00 30-JAN-04 08-NOV-04
    For each record having the same num, i want only one record picked, and that one should not have udate blank.
    How can I do this using ROWNUM?

    ...but there is a pitfall when the columns in selection list are not the same to
    columns in order by. Here unique can't help (while row_number() will
    also return one row (another question is it wnat you need or not):
    Compare:
    SQL> select ename, deptno,sal from emp_1 order by 2,1;
    ENAME          DEPTNO        SAL
    CLARK              10       1225
    CLARK              10       2450
    KING               10       2500
    KING               10       5000
    MILLER             10        650
    MILLER             10       1300
    ADAMS              20        550
    ADAMS              20       1100
    FORD               20       1500
    FORD               20       3000
    JONES              20     1487,5
    JONES              20       2975
    SCOTT              20       1500
    SCOTT              20       3000
    SMITH              20        500
    SMITH              20       1000
    ALLEN              30        900
    ALLEN              30       1800
    BLAKE              30       1425
    BLAKE              30       2850
    JAMES              30        560
    JAMES              30       1120
    MARTIN             30        625
    MARTIN             30       1250
    TURNER             30        750
    TURNER             30       1500
    WARD               30        725
    WARD               30       1450
    28 rows selected.
    SQL> select ename, deptno, sal from
      2  (select ename, deptno, sal,
      3  dense_rank() over(partition by deptno order by ename) rn
      4  from emp_1) where rn = 1
      5  /
    ENAME          DEPTNO        SAL
    CLARK              10       1225
    CLARK              10       2450
    ADAMS              20        550
    ADAMS              20       1100
    ALLEN              30        900
    ALLEN              30       1800
    6 rows selected.
    SQL> select unique ename, deptno, sal from
      2  (select ename, deptno, sal,
      3  dense_rank() over(partition by deptno order by ename) rn
      4  from emp_1) where rn = 1
      5  /
    ENAME          DEPTNO        SAL
    CLARK              10       1225
    CLARK              10       2450
    ADAMS              20        550
    ADAMS              20       1100
    ALLEN              30        900
    ALLEN              30       1800
    6 rows selected.
    SQL> select ename, deptno, sal from
      2  (select ename, deptno, sal,
      3  row_number() over(partition by deptno order by ename) rn
      4  from emp_1) where rn = 1
      5  /
    ENAME          DEPTNO        SAL
    CLARK              10       1225
    ADAMS              20        550
    ALLEN              30        900Rgds.

  • Want to retrieve null value from xml?

    i m writing this code to get the tag name and values from xml file.
    Now the problem is that
    if my xml file contain any tag whose value is not defined like
    <root>
    <firsttag>first</firsttag>
    <Second></Second><Third>third</Third>
    </root>
    Now look if second tag doesnt contain anything ,then i want to add "null" to vector,but it throws null pointer exception because second tag is empty.
    Vector<String> CSWFinfo = new Vector<String>();
              try {
                   DocumentBuilderFactory factory = DocumentBuilderFactory
                             .newInstance();
                   DocumentBuilder builder = factory.newDocumentBuilder();
                   Document doc = builder.parse(new File(xml));
                   Element root = doc.getDocumentElement();
                   NodeList node = root.getChildNodes();
                   for (int i = 0; i < node.getLength(); i++) {
                        Node currentNode = node.item(i);
                        if (isTextNode(currentNode))
                             continue;
                        CSWFinfo.addElement(currentNode.getNodeName());
                        if (null != currentNode.getFirstChild().getNodeValue()) {
                             CSWFinfo.addElement(currentNode.getFirstChild()
                                       .getNodeValue());
                        } else {
                             CSWFinfo.addElement("null");
                   }//end of for loop block
                   System.out.println(CSWFinfo);
              } catch (Exception e) {
                   e.printStackTrace();
                   // TODO: handle exception
              }I am using dom parser .
    Can any one know how to do it????
    Edited by: chauhan2003 on 16 Jun, 2008 12:06 PM

    Are you sure that all currentNode have a firstChild ????
    If your node has no value, it has no child
    So i 'd change code to like look something like:
    if (currentNode.getFirstChild() != null) {
         CSWFinfo.addElement(currentNode.getFirstChild().getNodeValue());
    } else {
         CSWFinfo.addElement("null");
    }

  • My hard drive crashed on my apple computer recently. I have a new one, but it won't sync with apple tv1, and I want to retrieve my photos from teh appletv1. It appears in devices now, but won't let me go any further with it. Help

    The hard drive crashed on my apple computer and I lost a lot of photos. I want to recover them from my apple tv1, but the computer won't seem to pair up with the apple tv. The Apple tv does appear in devices, but it won't let me go any further. The 'apply' button is a pale grey colour and you can't click on it. Help!!

    there is no facility to recover your photos from the appletv.
    the only way to link the appletv to your new "system" is to remove the existing itunes link and then link it to the new itunes - this will delete all content from the appletv though.

  • Getting the first row from a ResultSet??

    I have a query that returns a set of values but am interested only in the first value.How can I get that. I tried to use getArray method but that gives a "java.sql.SQLException: Exhausted Resultset".
    Any suggestions??

    I think I'm having the same problem with you.
    this is my method:
    private Vector getData( ResultSet rs){
    String str = "";
    try{
    while( rs.next() ){
    str = rs.getString( 1 );
    rows.addElement( str );
    }catch( SQLException sqlex ){
    sqlex.printStackTrace();
    return rows;
    I don' t know if you meant this.hoping this can help you

Maybe you are looking for

  • Can't find my overdrive audiobook on my ipad

    Hello, I'm looking for some help with a library audiobook from the Harris County Public Library.  I have an original ipad running the latest OS.  The book is WMA format, and I have it checked out until 1/27/12.  Here is what I have done so far: The m

  • SOAP in XI: message use="encoded" and binding/@style="rpc"

    Hi Hope somebody who is familiar with XIs SOAP implementation could give the answer for my questions. Problem is that the SOAP server is not working but I am afraid that the reasons are not really simple. In our company we have to provide some SOAP s

  • Events invitations are note added into the Calendar

    I have a back end and front end calendar 6.3 environment with convergence connecting to the front end. When [email protected] invite the [email protected] to an event only an email notification of the event is sent to the userB, the invitation is not

  • When I click the icon at the top left of the page, all I ever get is refresh or close , never the Moztlla Firefox page

    When I click on the icon at the top left of the page all I ever get is refresh or close. never the Mozilla Firefox page. I have downloaded Firefox , but never get any further. What can I do about this problem?

  • Enable Javascript in editor - how ?

    I need to have javascript working in the editor so that I can see my "hidden" stuff The idea is that I have lots of form code hidden IF a user does not have javascript enabled (lots of form validation code) However, for the sake of building that form