Control the loop of resultset.next( ); (method)

Hai, guys
I am using the ODBC database connection to (Excel Sheet) and i wanna get the records from it. My code is scucess but there is a problem in resultset.next() method.
The thing is it retrieving all the data including the none data fields (null null), so finally it became a never ending loop.
pls help me to get the data rang's records
Statement stmnt = connexl.createStatement();
String query = "SELECT * FROM [IJTS$]";
stmnt.execute(query);
ResultSet rsxl = stmnt.getResultSet();
while(rsxl.next()) {
String excelname = rsxl.getString(1);
String excelcate = rsxl.getString(2);
System.out.print(rsxl.getString(1));
System.out.println(" "+rsxl.getString(2));
}

if null implies it has reached the last row, maybe you could check for null and break from the loop
for example:
while (rsxl.next()) {
  String excelname = rsxl.getString(1);
  String excelcate = rsxl.getString(2);
  if (excelname == null && excelcate == null) {
    break;
  } else {
    System.out.println(excelname + " " + excelcate);
}

Similar Messages

  • How to control the looping time of the for loop in 10 microseconds in labview?

    I need to create a +/- 9 volt square wave with period of 20us using a D/A card (Not NI card). I can write command to the card using outport provide by Labview. Right now, I can generate square wave with 4ms period which is limited by the resolution of the wait until next ms icon I used inside the for loop. Could anyone tell me how to control the execution time of the for loop to about 10 us? Your help would be much appreciated.

    I'm not sure if this will hep, but this answer seems to answer this question
    http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=50650000000800000029410000&UCATEGORY_0=_30_%24_12_&UCATEGORY_S=0&USEARCHCONTEXT_QUESTION_0=microsecond+resolution+1ms&USEARCHCONTEXT_QUESTION_S=0

  • How to control the depreciation for revaluation from next month ?

    Dear all,
    I post current year ord. depreciation revaluation via trx. ABAW (Bal. Sheet Revaluation), and the general ledger will be updated after depreciation run.
    In our client, the scenario is  AFAB (dep run) --> ABAW (revaluation) --> AFAB (dep repeat run).
    Now my problem is I want the revaluation value be depreciated next month and the second AFAB just for general ledger posting.   I have set the period control '11'(next month) for revaluation but  it doesn't work, the second AFAB still generates both G/L and depreciation posting.
    How can I control the revaluation depreciation from next month?
    Thanks for your help.

    Hi,
    we have used a different approach. We run two separate depreciation areas:
    01 - ordinary depreciation
    03 - revaluation
    We maintain two complete streams of data. 01 is linked to the original acquisition value of the asset and depreciates normally.
    03 is linked to the revaluation. Each month we recalculate the replacement value, revalue the accumulated depreciation and then run depreciation using transaction AFAB.
    I don't think it will work in the way you described.
    Kind regards,
    Rudolf

  • Resultset.next() Issue

    Okay I have narrow my issue down to activity involved with the resultset.next() method. What is happening is I am working through a small resultset--3 records. These records are made up of columns from 3 seaprate tables (9 total). Some of these tables have many records (> 3K) in them. I moved the SQL statement in a store procedure so we can execute the query in a faster manner. The store procedure is returning the information in only 46ms. However, when I start looking through the resultset on the app server, it is taking 19K ms for the first time through the loop.
    I am at a lost to explain why the first iteration is taking so long. I have looked back at the SQL statement. I use alias names for the tables. I identify the column names in the select statement, but I do not use aliases for the column names. I am wondering if my problem is connected to the fact that the Oracle Driver
    maybe going back to get the column names the first time through the result set. I am not using the column name to index into the resultset. If my theory is right, this would explain the high latency. If I am wrong, I am stumped.
    Any suggestions or help explaining this would be greatly appreciated.
    As always, thanks for reading my post.
    Russ

    Execution of a CallableStatement (Procedure) is relatively fast. Getting ResultSet back is fast. But First iteration over the result set takes a lot of time comparing to the following iterations.
    Part of the code :
    long start=System.currentTimeMillis();
    int i=0;
    long local=System.currentTimeMillis();
    while(rs.next()){
    if (i==0){
    MetricsUtil.printTime("ResultSetRowHolder.getRows(ResultSet rs) ["+list.size()+" ]",local);
    local=System.currentTimeMillis();
    hol=new ResultSetRowHolder(rs);
    list.add(hol);
    i++;
    if (i%100==0){
    MetricsUtil.printTime("ResultSetRowHolder.getRows(ResultSet rs) ["+list.size()+" ]",local);
    local=System.currentTimeMillis();
    MetricsUtil.printTime("ResultSetRowHolder.getRows(ResultSet rs) ["+list.size()+" ]",start);
    Printouts
    Metrics << QueryHelper.executeStatement() >> Total time -> 2.836 sec
    Metrics << ResultSetRowHolder.getRows(ResultSet rs) [0 ] >> Total time -> 13.867 sec
    Metrics << ResultSetRowHolder.getRows(ResultSet rs) [100 ] >> Total time -> 0.48 sec
    Metrics << ResultSetRowHolder.getRows(ResultSet rs) [200 ] >> Total time -> 0.44 sec
    Metrics << ResultSetRowHolder.getRows(ResultSet rs) [300 ] >> Total time -> 0.47 sec
    Metrics << ResultSetRowHolder.getRows(ResultSet rs) [400 ] >> Total time -> 0.38 sec
    Metrics << ResultSetRowHolder.getRows(ResultSet rs) [500 ] >> Total time -> 0.37 sec
    Metrics << ResultSetRowHolder.getRows(ResultSet rs) [600 ] >> Total time -> 0.38 sec
    Metrics << ResultSetRowHolder.getRows(ResultSet rs) [700 ] >> Total time -> 0.35 sec
    Metrics << ResultSetRowHolder.getRows(ResultSet rs) [800 ] >> Total time -> 0.34 sec
    Metrics << ResultSetRowHolder.getRows(ResultSet rs) [900 ] >> Total time -> 0.32 sec
    Metrics << ResultSetRowHolder.getRows(ResultSet rs) [1000 ] >> Total time -> 0.34 sec
    Metrics << ResultSetRowHolder.getRows(ResultSet rs) [1100 ] >> Total time -> 0.41 sec
    Metrics << ResultSetRowHolder.getRows(ResultSet rs) [1200 ] >> Total time -> 0.32 sec
    Metrics << ResultSetRowHolder.getRows(ResultSet rs) [1230 ] >> Total time -> 14.340 sec

  • ResultSet.next() throws exception

    I am working on a BEA Weblogic application migration from 7.1 to 8.1. My application has lots of Oracle user defined package functions for providing database query. Those functions return a cursor pointing to the query results (ResultSet object in JDBC). My BEA Weblogic 8.1 java application, which invokes those Oracle functions, uses getObject() method to get query ResultSet. Follows are a java code snippet and exception thrown when using ResultSet.next() method to move cursor. Thanks.
    =================== code snippet ========================
    CallableStatement cs1 = (CallableStatement)conn.prepareCall("{? = call pkg_profile.fn_get_user_data(?) }");
    cs1.registerOutParameter(1, java.sql.Types.OTHER);
    cs1.setString (2, c_strUsername);
    cs1.execute();
    // Get the Result
    ResultSet rs1 = (ResultSet)cs1.getObject(1);
    if (rs1 == null || !rs1.next()) { <=== exception thrown due to moving cursor to the next row of query result.
    =================== code snippet =======================
    Exception -
    ERROR 24 Nov 2004 12:19:28,527 USER:supuser - CNTXT:MISUserProfile.userDataDispatcher | SQL Error while retrieving data for user. | java.sql.SQLException: java.lang.NullPointerException: CDA is null
    Start server side stack trace:
    java.lang.NullPointerException: CDA is null
    at weblogic.db.oci.OciCursor.arrayFetch(Native Method)
    at weblogic.db.oci.OciCursor.oci_arrayFetch(OciCursor.java:2338)
    at weblogic.jdbc.oci.ResultSet.next(ResultSet.java:774)
    at weblogic.jdbc.rmi.internal.ResultSetImpl.next(ResultSetImpl.java:135)
    at weblogic.jdbc.rmi.internal.ResultSetImpl_WLSkel.invoke(Unknown Source)
    at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:362)
    at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:313)
    at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:821)
    at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:308)
    at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:213)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:189)
    End server side stack trace

    Try this one...
    Before excecuting the query setAutoCommit false and then try to execute the query.After executing query manually do commit.It should work.

  • How do I create a 1d array that takes a single calculation and insert the result into the first row and then the next calculation the next time the loop passes that point and puts the results in thsecond row and so on until the loop is exited.

    The attached file is work inprogress, with some dummy data sp that I can test it out without having to connect to equipment.
    The second tab is the one that I am having the problem with. the output array from the replace element appears to be starting at the index position of 1 rather than 0 but that is ok it is still show that the new data is placed in incrementing element locations. However the main array that I am trying to build that is suppose to take each new calculation and place it in the next index(row) does not ap
    pear to be working or at least I am not getting any indication on the inidcator.
    Basically what I am attempting to do is is gather some pulses from adevice for a minute, place the results for a calculation, so that it displays then do the same again the next minute, but put these result in the next row and so on until the specifiied time has expired and the loop exits. I need to have all results displayed and keep building the array(display until, the end of the test)Eventually I will have to include a min max section that displays the min and max values calculated, but that should be easy with the min max function.Actually I thought this should have been easy but, I gues I can not see the forest through the trees. Can any one help to slear this up for me.
    Attachments:
    regulation_tester_7_loops.vi ‏244 KB

    I didn't really have time to dig in and understand your program in depth,
    but I have a few tips for you that might things a bit easier:
    - You use local variables excessively which really complicates things. Try
    not to use them and it will make your life easier.
    - If you flowchart the design (very similar to a dataflow diagram, keep in
    mind!) you want to gather data, calculate a value from that data, store the
    calculation in an array, and loop while the time is in a certain range. So
    theres really not much need for a sequence as long as you get rid of the
    local variables (sequences also complicate things)
    - You loop again if timepassed+1 is still less than some constant. Rather
    than messing with locals it seems so much easier to use a shiftregister (if
    absolutely necessary) or in this case base it upon the number of iterations
    of the loop. In this case it looks like "time passed" is the same thing as
    the number of loop iterations, but I didn't check closely. There's an i
    terminal in your whileloop to read for the number of iterations.
    - After having simplified your design by eliminating unnecessary sequence
    and local variables, you should be able to draw out the labview diagram.
    Don't try to use the "insert into array" vis since theres no need. Each
    iteration of your loop calculates a number which goes into the next position
    of the array right? Pass your result outside the loop, and enable indexing
    on the terminal so Labview automatically generates the array for you. If
    your calculation is a function of previous data, then use a shift register
    to keep previous values around.
    I wish you luck. Post again if you have any questions. Without a more
    detailed understanding of your task at hand it's kind of hard to post actual
    code suggestions for you.
    -joey
    "nelsons" wrote in message
    news:[email protected]...
    > how do I create a 1d array that takes a single calculation and insert
    > the result into the first row and then the next calculation the next
    > time the loop passes that point and puts the results in thsecond row
    > and so on until the loop is exited.
    >
    > The attached file is work inprogress, with some dummy data sp that I
    > can test it out without having to connect to equipment.
    > The second tab is the one that I am having the problem with. the
    > output array from the replace element appears to be starting at the
    > index position of 1 rather than 0 but that is ok it is still show that
    > the new data is placed in incrementing element locations. However the
    > main array that I am trying to build that is suppose to take each new
    > calculation and place it in the next index(row) does not appear to be
    > working or at least I am not getting any indication on the inidcator.
    >
    > Basically what I am attempting to do is is gather some pulses from
    > adevice for a minute, place the results for a calculation, so that it
    > displays then do the same again the next minute, but put these result
    > in the next row and so on until the specifiied time has expired and
    > the loop exits. I need to have all results displayed and keep building
    > the array(display until, the end of the test)Eventually I will have to
    > include a min max section that displays the min and max values
    > calculated, but that should be easy with the min max function.Actually
    > I thought this should have been easy but, I gues I can not see the
    > forest through the trees. Can any one help to slear this up for me.

  • Not Breaking the loop but how to continue with the next iteration in a For

    Hi all
    i have the following piece of code
    Please let me know, what is the /*some construct*/ which will not break the loop but goes to the next iteration skipping Login b
    Loop
    Login A
    /*some construct*/
    Login B
    End loop;
    P.S
    I should do this without Label or Exception ... I am using oracle 8i
    Thanks
    Hariharan
    T

    An [url http://www.oracle.com/pls/tahiti/tahiti.tabbed?section=48911]IF statement?
    loop
      login_a;
      if false
      then
        login_b;
      end if;
    end loop;Regards,
    Rob.

  • Run a loop when there is any change in value of any control or local variable in side the loop

    I am trying to write a program for a complicated multivariate system. I have many different controls connected to different functionality of the system. What I want to do is, run a continuous time loop, but I don't want the program to go over all the different controls and execute all the different functions. Instead can I do the job in a way, that the program will only execute the part that has changes in its control compared to its last loop and not go over the rest of the program in the loop? Hope I make my problem clear!

    Have a look at my idea here. The code shown on the left can be done with current tools.
    LabVIEW Champion . Do more with less code and in less time .

  • A bug in the ResultSet.getString method?

    Hi,
    I am using a 8.1.6 database with UTF8 character set on a Win2000 machine. I've inserted some Hebrew characters into a table, and have been able to read them back properly using SQL+.
    However, when I try to retrieve these values from a simple Java program using the resultSet.getString method (via Oracle JDBC driver 8.1.6) I always get the '?' character for every Hebrew character (English characters work fine). However, if I call the 'getBytes' method of the result set, and create a new String instance from that data, it works fine - help needed!
    Thanks...
    null

    However, if I call the 'getBytes' method of the result set, and create a new String instance from that data, it works fine - help needed!Thanks...
    Please show me how to using 'getBytes' method of the result set and create a new string instance from THAT DATA, because this way doesn't work for me. I am converting ZHT16DBT to Unicode, and all I got is ?????.
    Please help me if you have any idea. THANKS
    null

  • How to make the LV front panel controls the current value through the program is set as the default value when the next time you open?

    How to make the LV front panel controls the current value through the programis set as the default value when the next time you open?
    1110340051 

    Try this: Re: How to make a VI remember the latest control value?
    Jim
    You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice

  • I want to ask next have ADOBE READER API? I want to control the ADOBE READER right-cli

    Good evening! I want to ask next have ADOBE READER API? I want to control the ADOBE READER right-click and shortcut, and the navigation buttons on the article? Thanks for the reply

    Moved to Acrobat SDK

  • Sun:Iterating the cursor ! Is this bad logic. i.e, using crs.next() method

    Hi friends,
    I have been using crs.next() method for comparing the given string in textbox and in database are equal. If they are equal then it must redirect to other page otherwise it must remain in the same page.
    Please tell me wheter it is bad logic or not.If it is bad logic then tell me the alternate one.
    Thanking you in Advance.

    Are you refering your code in:
    http://forum.java.sun.com/thread.jspa?threadID=5121734&tstart=75 ?
    I don't know about bad logic or not in using crs.next().
    But I am just curious why do you have to iterate the rowset when you can set a query criteria in the rowset? Suppose you have 100 records in your table, sure it is faster to use query criteria for that., execute the rowset, and then check whether the rowset contains a record or not.
    Another alternative is to use tableDataProvider.findFirst(), and then check the existence of the record. That if you use tableDataProvider instead of the rowset directly. (You may find it in JumpStartCycle sample project).
    Also instead of writing these lines:
    // set the rowset to use the Employee database
    rs.setDataSourceName("java:comp/env/jdbc/Employee");
    rs.setCommand("SELECT * FROM srni.EMPLOYEE");
    rs.setTableName("EMPLOYEE");in the login_action(), you may visually create the rowset() and put it in sessionbean.
    That is what I've found in JSC sample projects. In JumpStartCycles sample (you may create it via file-new projects-samples), there is a login.jsp which is quite similar to your login form. Not exactly the same, but the logic is the same.
    rgds

  • HT1338 I can't final close Safari with control Q. It just open next time on the closed page.

    I can't final close Safari with control Q. It just open next time on the closed page.

    To prevent Safari opening your last closed pages again you can do one of three things.
    1. Close the pages before closing Safari (eg. open homepage before closing Safari)
    2. Hold Shift while opening Safari (this will start Safari from homepage)
    3. Browse in 'Private Browsing'.

  • How to find the next record b4 the loop end

    hai all
    i have suffering big problem... i have the  internal table  call IT_ITAB.. so i can go to the rerecord by record using loop comand..
    example:
    loop at IT_ITAB.
    1.record1
    2.record2
    3.record3
    4.record4
    endloop.
    Allways end of loop go to next record...... my problem is before end of the loop i want to check the next record... how should i do it... please help me...
    regard
    nawa

    Hi,
    One approach u can follow is that copy the data of the internal table into another one.
    Maintain an integer type variable which will contain the index value of the loop. Check the entry from other table.
    e.g.
    Loop at itab1.
    ctr = sy-tabix + 1.
    read itab2 index ctr.
    This way u can check the next record while u r still in loop.
    Hope it helps.
    Regards,
    Himanshu

  • Can we cascade PID and PIV loops to control the servo motor

    hi
    presently we are using PID loop for controlling the motion of a servo motor using ni-7352 card. We  are not able to receive the desired response from this implemenatation. So is there any other alternative like using a PIV loop or using PID cascaded with PIV to achieve a better response. If there is possibility help us to proceed further with this.
     also tell us which is more reliable 1)using PID alone  2) Using PIV Alone 3) using PIV and PID cascaded.
    please mail to this query to [email protected]

    Sidda,
    before you start thinking about advanced control architectures I want to ask you to tell me some details about your system behavior and the control parameters that you have used. I have used 73xx boards for very dynamical systems and I have always been able to find control parameters that resulted in a very fast and stable system behavior.
    For the case that you need some help with tuning please have a look at this link. In many cases autotuning doesn't result in good system behavior but you will find a lot of interesting hints about the manual tuning process there (e. g. that increasing the Kd gain typically results in a better damped system).
    If this doesn't help please attach some screenshots from your step response and the control parameters that you have used.
    Best regards,
    Jochen Klier
    National Instruments Germany

Maybe you are looking for

  • Blue screen error /Blue screen of death(Your pc ran into a problem and needs to be restart)

    Hello,          About 15 days ago,my laptop is showing blue screen errors,really this is very frustrating.          I use a lenovo laptop, Processor Core i3 (3rd Generation) System Memory 4 GB DDR3 HDD Capacity 320 GB Operating System Windows 8 Syste

  • Video content missing on ipad... play buttons greyed out

    There was a similar thread but answer did not apply.  I have videos that are fromatted to play on ipad and play in itunes well.  When sync to ipad you can see the ipad increase in file size from the added video.  When you open the video app to view t

  • How can access MS Outlook Calender information  from my Java application.

    People schedule meeting with some data on regular basis. I need to access the Exchange server from my Java application and get the meeting dates along with other data pertaining to meeting.

  • Multiple relationship modeling

    Hello, I am hitting a bug/issues/misunderstanding on my side with data modeller 4.0.0.833 (I had this issue in the previous versions too). I was trying to model multiple relationships from a entity to a detail entity and am hitting some problems. I h

  • [SOLVED] sed; string with file

    Hi, Is it possible the to replace a string with file contents, for example; i have the following XML file: <?xml version="1.0" encoding="UTF-8"?> <modification> <id>Testing</id> <version>0.0.1</version> <vqmver required="true">2.5.0</vqmver> <author>