Problem of iteration ResultSet

Scenario is,

I have a ResultSet rs, contained some database data, once I visit any rs and display data from it, then call rs.beforeFirst (); to iterate again but this time it doesn't show any output, my code is below

try {}
While (RS. Next())
{
System.out.println ("Dash first" + rs.getString (1));
}
}
catch (SQLException ex)
{

}

Try
{
rs.beforeFirst ();
While (RS. Next())
{
System.out.println ("time 2nd iteration" + rs.getString (1));
}
}
catch (SQLException ex)
{
}

This is according to the type of result set, default type is TYPE_FORWARD_ONLY cursors, it means that the cursor moves forward only in this case you cannot use rs.beforeFirst (); What you can do is to re - run once again the statement as:

      rs = stat.executeQuery();
      while (rs.next())
      {
        System.out.println(rs.getString(1) + "   - 1st time Iterating");
      }
      System.out.println("------------------------------");
      rs = stat.executeQuery();
      while (rs.next())
      {
        System.out.println(rs.getString(1) + "   - 2nd time Iterating");
      }

If you want the cursor result set can move forward and backward in the ResultSet Type TYPE_SCROLL_INSENSITIVE value and in this case, you can use rs.beforeFirst (); as:

      conn = getConnection();
      Statement stat = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE , ResultSet.CONCUR_READ_ONLY);
      String sql = "select department_name from departments";
      rs = stat.executeQuery(sql);
      while (rs.next())
      {
        System.out.println(rs.getString(1) + "   - 1st time Iterating");
      }
      System.out.println("------------------------------");
      rs.beforeFirst();
      while (rs.next())
      {
        System.out.println(rs.getString(1) + "   - 2nd time Iterating");
      }

Tags: Java

Similar Questions

  • Problem with iterator and EJB data control

    My project components:

    JDeveloper 12.1.3

    Back end & the intermediate layer, JPA, EJB 3, controls data EJB

    JSF pages simple front end (no fragment), bounded task flow

    Hello

    I have a weird problem with iterators in my project, project using EJB 3 & JPA and EJB data controls

    When the user come to a page (this page is part of a stubborn workflow) and add a record to a table (linked to an iterator) and without saving changes, leave the page (means output delimited task flow)

    do something else and again back to the first page iterator always keep this line is entry and it cause problems in my system

    If I close the browser and come to this page for sure the line is not there

    I expect when the user leaving a stubborn workflow each thing belongs to this workflow should be deleted. Is this true?

    Or someone has the same problem? Any suggestions / or work around?

    Respect of

    Mohsen

    Have you read the link I posted? Have you named the BA a transactional data control?

    When you leave the workflow you issue a rllback and the new line should have disappeared.

    Timo

  • Communication with EtherCAT defective modules with executable startup

    Hello

    I have a deployment with a hypervisor OR 3110 and four NI 9144 chassis that are connected via EtherCAT. The RT VI I created works perfectly when they are deployed since in the LabView project. However, when I create a start executable (startup.rtexe), it fails somehow communicate with 3 out of the 4 chassis. I can read/set values for the frame that plugs directly into the hypervisor, but cannot control the chassis more far. If I build the executable to start with debugging enabled, the behavior is the same. Strangely, when I connect to the startup.rtexe running through the 'Debug Application or Shared Library' menu in the LabView project, I start getting values as it should. When I disconnect from the debug version, I lose the modules again.

    What I'm missing here?

    Thank you much for the help.

    Christoph

    I found the root of the problem: for iterations inside my call loops, I use property on variables unconnected (type defs) nodes to determine the number of iterations that I need. This doesn't seem to work if the FP is closed, as is the case in a deployed executable startup. If I replace these nodes of property with the constants, everything works as expected. It semms that the compiler removes variables unconnetced, because it "thinks" that they are not used.

  • Initialize table?

    Buenas, Porque El preguntaros first not be muestran Los Datos En El 'output array. Bij appear same Los problemas "tabla iter."

    No "constant matriz" TR Es Por if, as services can?

    Of Cuando solucione preguntare ESTO Algo mas Complejo os.

    Gracias Por adelantado

    Hi pescajaime,

    The VI "Insert table" inserts a table n-1 dim in a table of size n to the specified index. In the attached screenshots I guess that a constant variety of dimension 2 is connected to the entry of the "insert in Array. I also assume that you do that add items to the first column of this table of 2 size (what is more, I guess you just add a 1 element at index 0.0 this table). If this is the case, you can only insert an array of 1 dimension for the first column of table 2 original size.

    Therefore, when you cable the output array of the VI that is associated with the HS1560 device for the "new item/sub-table" entry "Insert table", VI this VI is just the first line insertion of the 2 dimension table. I guess that the specified index is 0 (0 times 5 is equal to 0), so LabVIEW is the first line of the 2 array dimension inserting this device ouptus the 'HS1560' in the first column of the original array. If you compare "output table" and "Tabla iter" indicators you can check that the first column of the "iter Table" has been added to the first column of the table of origin at index 0. Since this column caontains 11 loose, a '1' is located in the 12th position of the column. The attached extract shows this behavior.

    To insert the entire table of dimension 2 'Table iter' in the constant table, you add to the table constant as many elements as the number of lines containing 'Table iter. "

    I hope this helps.

  • How to check if a page item is outside of a page

    Hi all

    I'm a developer to do some automation in InDesign, using scripts via .NET. As I am a developer, I'm not really fluent in the language of the page layout, please bear with me.

    My script creates a variable amount of TextFrame on a page and move them and then turn them. Some of them could leave the page on the right side. If only one bottom right of the image the text anchor point lies outside of the page to the right, I need to detect. There is no problem to iterating through blocks of text, but the challenge is how to determine if the anchor from the bottom right of the image of a text is positioned outside of the page.

    I watched GeometricBounds, but as soon as the post is to the right of the page, the coordinates start from 0. So I can't do as GeometricBounds.X > Page.Width, because GeometricBounds.X will be less than Page.Width when it is to the right of the page.

    I also looked at PageItem.Resolve, but that work really confuses me. I tried to fix the anchor point to the coordinates of cardboard, and that seems to work very well. But then I have to get the right edge of the page in coordinates of cardboard, and it seems not that I can use PageItem.Resolve to get that.

    I looked at the guide to programming to understand how the different coordinate systems work together, but when I use PageItem.Resolve, I get results that does not seem to be exact, where the coordinate systems must be.

    I don't know that it is easy to detect if a block of text is outside of a page, but I just need a pointer in the right direction. Can someone help me with this? :-)

    Thanks in advance.

    PS: I'm scripts for InDesign CS3.

    (1) use visibleBounds instead of geometricBounds (for processed objects).

    (2) set the rulerOrigin to spread.

    (3) do not use .NET, unless you live a painful experience.

    Good luck

    Substances

  • New version 9.0.1 on Windows 7 has a problem by running JavaScript math iterations.

    Error dialog box reads:
    A script on this page may be busy, or it may have stopped responding. You can stop the script now, or you can continue to see if the script ends.

    Script: http://www.classictesla.com/java/javatc/script/JTC_geotc.js:1299

    The dialog box above has never before imagined. This program is very well forever and has not changed. With Firefox 8, the program is run in 0.3 seconds. IMMEDIATELY that I welcomed the browser upgraded to version 9.0.1, the program is now not working.

    About 1,000 people use this program. Conscious slow corrections can be, I have to inform does not to allow FF upgrade to version 9. Really sucks as I've been a FF fan forever.

    If you go to this Web site, click on the button "Load Sample reel", then scroll down and click the button RUN JAVATC, you will see the problem

    If there is a problem with the script, why only now after so many years of running? I can run fine on version 8. If there is something I can do on my end, I'd like to (just tell me what is the problem).

    My guess = ' version 9 is limiting the number of iterations can execute a script. Copy the following code to run in 0.3 seconds and now is just hung. A very sad day for me. I guess I have to find a way to return to the old version 8.

    I can't return my Firefox to Version 8 and I can't find anywhere on the net, I need to remember to manually download each new version, so I have a copy of backup in case it has some bugs, so I can go back to the old, now I'm stuck with Version 9

  • Problem when running iterative morphology

    Hi all

    I'm writing a VI that takes an input image and uses the morphological operations until the stop condition is met (the condition is linked with the resulting image). I want to retain the images obtained at each iteration. I tried to do with records to offset and creting a table of the image. Unfortunately, none of these reviews has worked... For some reason, the morphological operation affect my input image, so that all the images stored in the table show the result of the latest iteration. I tried to create a copy of the image in each iteration without success. I created a simplified example to illustrate the problem. I use a loop for whiich makes expansion n to an image of input text. I expect a result different dilated images stored in the output array. Anyone know what could be the reason for my problem?

    Thanks in advance.

    PS: I know I could specify the number of iterations that runs from the morphology of VI, but I do not know this number in advance. I need to apply morphological operations until meeting a condition evaluated in the loop. The idea is to transmit the resulting image in a registry to offset and evaluate each dilated image until a given condition is met.

    Make sure that you create a new image with a unique name for each step you want to memorize.  Use the new image that the destination image.

    If you use an image with the same name, it is the same image and is crushed.

    Bruce

  • for iteration of loop problem

    Hello!

    I built this vi to record the data of air speed sensors two and analog signals that drive the two actuators. My problem is: the number of iterations, I put on the second image, the same number of iterations will be held at the third picture. The example below, I put initially the loop run for 20 seconds and the second loop to run for 3 minutes. When I run the program both loops ryn for 20 seconds. Any tips?

    Concerning

    It's because of the release of the first loop table. A for the loop performs an iteration to the smallest size of County or an array of N. You simply need to right click on the output, and then select disable indexing. No need to create an array of file names.

    p.s. Get rid of the structure of the sequence. It is not necessary.

  • Problem, assess the iterations

    Hello

    I have a following script

    mu_B = Zeros (1,21);

    for i = 01:21
    County = i;

    j = 1: 125

    mu_B (i) = mu_B (i) + (j) * R (Count);
    Count = count + 21;
    end

    end

    created in LabVIEW

    Do not get the required results and again I am not be able to know if it's an exact equivalent of the script mentioned above. Need help.

    Kind regards.

    Your script describes a matrix multiplication, mu = R * a, where mu is a (column) vector of 21 items, R is a matrix of 21 lines and 125 columns and a (column) vector of 125 lines.  In your case, R is a 1 d array, so we need to make a 2D with 21 lines and 125 columns table.  Once we do that, the problem is very simple to solve.

    It will be a good exercise for you to do by yourself (and we will help you, if you get stuck).  There is a function in the table palette called table of reshape - wire R on the left and your two index, 21, then (pull down) 125), and you will get the form R 2D on the output.  Integrate a loop For of R - have - you noticed the "tunnel of indexing" (it looks like a square within a square)?  If you look at the wire inside the loop, it isn't a double line, i.e. a 2D picture, but a single line, which means that it is a line of the table 2D.  You don't need what whether wire in the connector of the loop For - it automatically scroll each of the 21 lines of R.  Now put one in the loop - here you don't want indexing tunnel (because you want the table in its entirety, all 125 items, inside the loop), then right click 'a' tunnel and choose "disable indexing."  Now you have two arrays of 1 d 125-element, you need to multiply, element by element, - that's exactly what the LabVIEW function multiply.  Wiring of the output of this multiply through the loop For (notice another tunnel of indexation, this time turning each of 21 iterations of the loop in an array of 21 items, "mu".)  And you're done.

    So, what do you need to solve this problem?  A remodel, a loop For and the other multiply to operate.  Give it a try.

    Bob Schor

  • First iteration of a loop problem

    I'm having a problem with the first iteration of a while loop. I want to save all the data a data acquisition over a period of time. In order to keep the unique 'small' file, I'm doing a VI that produce a new file every 10 min. about. But the first file I want to do is not due to the following problem:

    The first time I use the DaqMX read in the loop, it returns a blank. Why does do that?

    I'm not entirely sure why, but I just set the number of samples to a specific value so that you do not need the function of Ms. wait 100 in the loop.

    Tone

  • problem - by clicking on the button loses the new line or resets the iterator

    Hello

    I use JDev 11.1.1.6. I created a page that is preceded in the taskflow by a method in the AppModule that creates a line on the iterator and inserts it. I have a button 'Next' in the page, which is supposed to make changes to attribute readonly on the input fields, and display a confirmation button.

    The problem: when I click on 'next', the empty fields that have been entered by the user on the page, is part of the first record in the iterator. It is as if, when the button "Next" has been clicked, the iterator has been somewhat refreshed and moved to the first original line, and entered values have been thrown in there... While my 'new' record is lost. Result: I lose my new record line, and entered values replace the values in the first previous row in the iterator.

    The code used to create the line before the page is loaded:

    Sender ViewObjectImpl = getSubmittersView3_1();

    Submitter.Reset ();

    ViewRowImpl submitterRow = submitter.createRow () (ViewRowImpl);

    submitter.insertRow (submitterRow);

    When the page is loaded initially, I printed the primary key on the line and a - 4 (which is good, it means new line)

    But when I print the primary key in the action of the button 'Next', 59, who has been the pharmacokinetics of the first original line I.

    The code that is used to print the primary key:

    seqNum int = Integer.parseInt (this.getAppModule () .getSubmittersView3_1 () .getCurrentRow () .getAttribute (0) m:System.NET.SocketAddress.ToString ());

    Then print seqNum.

    Please help.

    Found the problem.

    I had a button print at the bottom, which was my button "Cancel". In this paper, I got the code to remove additional items (i.e. unwanted ranks - since it is a Cancel button). And what was going on was that while rendering on the page, the code of the EEG for the go button was running and the removal of my new line! If the culprit here was go get code button is iterated in the rendering phase... something I didn't expect or know so far. Remove this code and change a command button solves the problem.

  • problem with ResultSet closed

    Hello everyone. I wrote a code which supposed to find info on the user by its id to a few db. When I run my program it fails in the second loop on the line:

    While (resultM.next ()) {}

    the error is:

    Exception in thread "main" java.sql.SQLException: operation not allowed after ResultSet class closed
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:929)
    at com.mysql.jdbc.ResultSetImpl.checkClosed(ResultSetImpl.java:795)
    at com.mysql.jdbc.ResultSetImpl.next(ResultSetImpl.java:7146)
    at newpackage.db.findHistoryPatient(db.java:109)
    at newpackage.db.main(db.java:29)

    Thank you very much for help!

    the code is:

    Statement = connect.createStatement () (declaration);
    Result set has the results of the SQL query

    resultSet = statement.executeQuery ("select * from FEEDBACK.visit where the patient = '" + id + "'");

    While (resultSet.next ()) {}
    System.out.println ("the user is correct");
    numH is a key to search for in history_medicines
    String numH = resultSet.getString ("num");
    String description = resultSet.getString ("description");

    resultM = statement.executeQuery ("select * from FEEDBACK.history_medicines where id_visit ='" + Integer.parseInt (numH) + "'" "");

    While (resultM.next ()) {}
    int id_medicines = resultM.getInt ("id_medicines");
    History = History.Concat (resultM.GetString("StartDate"). ToString()+ "-");
    History = History.concat (resultM.getString ("endDate") +"'");
    History = History.Concat (description + "");

    ResultSet resultSetH = null;
    resultSetH = statement.executeQuery ("select * from FEEDBACK.medicines where id = '" + id_medicines + "'");
    While (resultSetH.next ())
    History = History.Concat (resultSetH.GetString ("Name") +"'");
    History = History.Concat (resultSetH.GetString ("Name") +"'");
    String MedicinesName = findMedicinesName (resultM.getInt ("id_medicines"));

    System.out.Print (History);

    }

    }

    }
    {Finally
    Close();
    }

    user12163960 wrote:
    OK thanks, but how can I solve this problem?
    If in the first comic, I get all the id_visit and the second db I get all the info.

    I'm not JDBC, but it seems to me that this is no longer a question of Java.

    A single SQL SELECT with WHERE clauses can retrieve related records from all the tables.

    Also, I recommend to use the PreparedStatement class and avoid the declaration.

    DB

  • Iterator refresh problem

    Hello

    I see a weired behaviour when working with the iterator.

    Here's the thing I did and the problem IM facing with the iterator.

    Things I've done
    ===============
    1.I have a DTO and a java class named ServiceDelegate in my model. And I defined a method inside the ServiceDelegate with the return type of DTO.
    2 and presentations of this ServiceDelegate as control data.
    3. with the help of the DataControl, dragged the return type of the method (which is nothing else than DTO) as a search form with a submit to a jsff button.
    4. now, when the user enters the data for the first time... the DTO becomes populous and able to retrieve the information that was entered by the user into ServiceDelgate properly.
    5. that's fine.
    6.now, if the user tries to change the data that was already entered... and click on the button "submit". This time, the CDC is not in the ServiceDelegate.

    Finally, I am able to get the data of the Iterator (DTO) that for the first time. It is not for the second time and other work. If you open the page once more than the costs, it works fine.

    One of you has no idea about it, why it behaves this way.

    Here is the code of my def page.

    < methodIterator id = "* borrowerDetailIterator * «Binds ="editBorrowerDemographics.result "DataControl ="BorrowerServiceDelegate"="25"RangeSize»»
    BeanClass="org.tgslc.defaultmanagement.domain.Borrower"/ >

    < MasterBinding = accessorIterator "* borrowerDetailIterator *"lie = "person" "
    RangeSize = '25' DataControl = "BorrowerServiceDelegate."
    BeanClass = "org.tgslc.defaultmanagement.domain.Person"
    ID = "personIterator" / >

    < MasterBinding = accessorIterator "* borrowerDetailIterator *"lie = "address" "
    RangeSize = '25' DataControl = "BorrowerServiceDelegate."
    BeanClass = "org.tgslc.defaultmanagement.domain.PersonAddress"
    ID = "addressIterator" / >

    < MasterBinding = accessorIterator "* borrowerDetailIterator *"= "telephone1" lie "
    RangeSize = '25' DataControl = "BorrowerServiceDelegate."
    BeanClass = "org.tgslc.defaultmanagement.domain.PersonPhone"
    ID = "phone1Iterator" / >

    < MasterBinding = accessorIterator "* borrowerDetailIterator *"= "Téléphone2" lie "
    RangeSize = '25' DataControl = "BorrowerServiceDelegate."
    BeanClass = "org.tgslc.defaultmanagement.domain.PersonPhone"
    ID = "phone2Iterator" / >

    < MasterBinding = accessorIterator "* borrowerDetailIterator *"= "email1" lie "
    RangeSize = '25' DataControl = "BorrowerServiceDelegate."
    BeanClass = "org.tgslc.defaultmanagement.domain.PersonEmail"
    ID = "email1Iterator" / >

    < MasterBinding = accessorIterator "* borrowerDetailIterator *"= "email2" lie "
    RangeSize = '25' DataControl = "BorrowerServiceDelegate."
    BeanClass = "org.tgslc.defaultmanagement.domain.PersonEmail"
    ID = "email2Iterator" / >

    Kind regards
    Kiran kristelle

    Select iterator on pageDef and select Properties.
    Try to set CacheResult = false and refresh = always.

    Amit

  • Iterator sort criteria problem

    Hello world. I use Studio Edition Version 11.1.1.2.0.
    I have the problem that when I click on the sort criteria for any of the iterators on a page without attributes increase but this only happens for the given iterator. There are two other iterators on the page, and they seem to work very well. So I'm wondering if any of you have had the same problem and if you know what caused sound and how to solve it.

    If the iterator is based on a detail view object, it will not work. This looks like a bug Jdeveloper.
    For example CustomersVo is the master of OrdersVo.
    Create an iterator by developing the CustomersVo node, and then select OrdersVo.
    No attributes will be displayed in the sort criteria tab.

    You can manually enter the sort criteria by updating the source of the page definition.

    For example

        
          
            
          
       
    
  • ADF - problem of the iterator

    Hi all

    I have a next page definition:

    + <? XML version = "1.0" encoding = "UTF-8"? > +.
    + < pageDefinition xmlns = "http://xmlns.oracle.com/adfm/uimodel" +.
    version = "11.1.1.54.7" id = "fileListingTryPageDef".
    Package = "View.pageDefs" > "
    + < Settings / > +.
    + < executable > +.
    + < iterator lie = 'root' RangeSize = '25' DataControl = "fileManager" +.
    ID = "fileManagerIterator" / >
    + < accessorIterator MasterBinding = "fileManagerIterator" lie = "fileNames".
    RangeSize = "25" DataControl = "file manager".
    BeanClass = "java.lang.String" id = "fileNamesIterator" / > "
    + < / executables > +.
    + < bindings > +.
    + < tree IterBinding = "fileNamesIterator" id = "fileNames" > +.
    + < nodeDefinition Name = "fileNames0" > +.
    + < AttrNames > +.
    + < item Value = 'Elément' / > +.
    + < / AttrNames > +.
    + < / nodeDefinition > +.
    + < / tree > +.
    + < / links > +.
    + < / pageDefinition > +.


    In the bean to support, I have a following code and it gives me NPE while creating the Row object:

    Links DCBindingContainer = new DCBindingContainer();
    DCIteratorBinding iter = bindings.findIteratorBinding("fileNamesIterator");
    Line r = iter.getCurrentRow ();


    Please advice according to what might be a problem here...


    See you soon,.
    Matthew

    Hello

    Try this code instead of DCBindingContainer();

    BindingContext, bc is BindingContext.getCurrent ();
    Links DCBindingContainer = (DCBindingContainer) bc.getCurrentBindingsEntry ();

    Hope this helps

    Joseba

Maybe you are looking for

  • error in the "sender" field

    Hello! For several weeks I get letters from different clients in the teamwork.tsom site, but in the email client, I displayed the same first and last name of the sender.Http://joxi.ru/RkepU_3JTJAXYyTrW64 screenshot I already wrote in support of "team

  • HP daily Surprise

    I had HP daily Surprise on my computer for a couple of years and have never had this problem before. Daily canlendar arrives, but it is empty. It started around April 1, 2013. I have the Adobe Air update and all flash drives. I deleted try it and re-

  • How can I transfer a license of Windows 7 on a new computer? Step by step please

    Hey guys, I just build my first computer and I don't want to use the HARD drive from my old computer to the new. I was wondering if there is some way I can transfer my Windows 7 license from the old computer to my new computer? I would be grateful if

  • Is it possible to install codecs windows without installing windows media player?

    Is it possible to install codecs windows without installing windows media player? I N windows version and I really want to install the multimedia package, I want just the codecs, because without them Firefox isn't able to reproduce h.264 html5 video

  • AUDIT log can be found in DBA_AUDIT_TRAIL! where can I find it.

    Nice dayWorking on Oracle application 12.1.3DB 11.2.0.3OS Linux 6When I try to use enterprise manager or sql command audit, any activity on specific table"SELECT AUDITON hr.employeesWHENEVER IT FAILS;"Audit succeeded.I could not found the audit log i