How do you rollback on multiple db connections?

Hi I have a .ini that has a few db connections it makes (3 of them to be exact) I want the rollback method to rollback not only the db that it is having issues with the previous db's it touched. Here is my code if anyone has an idea that would be wonderful. Thank you. splitvals[i] are the dbs. so it gets one message to insert and it inserts it to one db than to the other db. the it starts the second message. the warning while loop is the real warning sql throws back if there is an issue.
public boolean insertit(Fillit data) {
          today = Calendar.getInstance().getTime();
          cal = Calendar.getInstance();
          cal.add(Calendar.DAY_OF_YEAR, -1);
          sqlFormat = new SimpleDateFormat("MM/dd/yyyy");
          todayString = sqlFormat.format(today);
          String parsedate = "";
          Properties props;
          Connection con = getConnection();
          props = loadProperties("seqnums.ini");
          String logDir = Settings.s(props, "LogDir", "");
          if (logDir.length() > 0)
               logDir += File.separator;
          try {
               log = Logging
                         .newLogger(logDir + "Fillsimport_%d.log", Level.FINEST);
               con.setAutoCommit(false);
          } catch (IOException ioe) {
               System.out.println("IOException: " + ioe);
               System.exit(-1);
          } catch (SQLException e1) {
               e1.printStackTrace();
               System.err
                         .print("Oops something went wrong, with database access.");
          StringBuilder result = new StringBuilder();
          //if date is autgenerated parses it for the msgid; else puts the user entered.
          if (data.getDate().equals("Autogenerated")) {parsedate = todayString.replace("/", "").trim();}
          else {parsedate = data.getDate().split(" ")[0].replace("/", "").trim();}
          //for loop for .ini configuration of what databases to hit.
          String[] splitvals = props.getProperty("Databases").split(" ");
          for (int i = 0; i < splitvals.length; i++) {
               //creates the string the user will insert; appendstring is if they entered any optional values.
               String insertit = "exec "
                         + splitvals[i]
                         + ".Trading.dbo.usp_insFillsImporter @MsgId='"
                         + createMsgID(data.getEndpoint(), parsedate, data
                                   .getOrderNumber()) +"'," data.getAppendString();
               insertit = insertit.substring(0, insertit.length() - 1);
               //logs each message sent to evert database
               log.info("Message attempting to send to database " + splitvals[i] + ":\n"
                         + insertit);
               try {
                    statement = con.createStatement();
                    statement.execute(insertit);
                    results = statement.getResultSet();
                    //warning is null then it completed, if not it appends the message SQL sends
                    SQLWarning warning = statement.getWarnings();
                    while (warning != null) {
                         result.append(warning.getMessage());
                         warning = warning.getNextWarning();
                         JOptionPane.showMessageDialog(null, result.toString()
                                   + "\n Try again.", "Result",
                                   JOptionPane.WARNING_MESSAGE);
                         log.severe(result.toString() + " Warning issued. \n");
                         con.rollback();
                         log.info(insertit+"\nYourmessage have been rolled back.");
                         break;
               } catch (Exception e) {
                    result.append(e.getMessage());
                    System.err.println(e.getStackTrace());
                    log.severe(e.getStackTrace().toString());
                    log.severe(result.toString() + "\t Bad SQL query?");
                    log.info(insertit+"\nYourmessage have been rolled back.");
                    JOptionPane.showMessageDialog(null, result.toString()
                              + "\n Try again.", "Result",
                              JOptionPane.WARNING_MESSAGE);
                              try {
                                   con.rollback();
                              } catch (SQLException e1) {
                                   // TODO Auto-generated catch block
                                   e1.printStackTrace();
          }//end of for loop
          //JOptionPane.showMessageDialog(null, "Command completed successfully","Result", JOptionPane.PLAIN_MESSAGE);
          return true;
     }

thanks im prolly just going to create a driver for the procedure instead of trying to code it. thanks for the suggestion im going to still look into it

Similar Messages

  • Itunes match  how do you to select multiple songs or do you click each one

    In ITunes match  how do you to select multiple songs to download to pc or do you have to click each one.

    First make sure you have the current version of iTunes, which is actually 10.5.1.  I had to manually download it from apples website, for some reason, it wouldnt auto-update.
    http://www.apple.com/itunes/download/
    Once that is complete, go to the iTunes store. In the Quick Links secion to the right, you should see iTunes Match. This will prompt you to activate your subscription to iTunes match.  After that it should ask you to add your computer and once youve done that, it should begin the process of scanning your library and adding it to the cloud
    Alternatively, once you activate your subscription, you can also go to the Store dropdown menu in iTunes and select Turn On iTunes Match.

  • How do you use the Multiple Item Information dialog box ???

    How do you use the Multiple Item Information dialog box ???
    Where are the instructions on how the information in the Multiple Item Information dialog box equates to ...
    1. The way iTunes sorts tracks and albums
    2. The reason to select a leading check box
    3. Why there are Option selections (Yes /No) and leading check boxes.
    4. Why some changes remain in the track info, but do not "take effect" in iTunes (Part of a compilation is an example)
    Looked in Help, Support, went to the local Genius bar for an hour, even arrainged a call from apple support ...
    Thanks

    As Christopher says, it's a compilation. Different tracks are by different artists.
    Setting the *Album Artist* field to *Various Artists* and setting *Part of a compilation* to Yes should be all that is required. Depending on your *Group compilations when browsing* setting ( I recommend On ) either should suffice but I suggest doing both.
    Based on your commentary, I selected all the "O Brother" tracks, and checked the boxes for everything line that was blank in the Info and the Sort panes. Only exceptions were the album name and the disc number 1 of 1 and the artwork. I blanked and checked anything else.
    That's not what I meant. When you select multiple tracks, only those values which +are already common+ to all tracks are displayed. Typically these will include Artist, though not with compilation albums, Album Artist, Album, No. of Tracks, Genre plus various sort fields. A blank value may indicate that different tracks have different values or it may be that the value is blank for all tracks. For the drop down values on the Options tab the value shown may not reflect the information in every tag. If values you expect to be common, such as Album Artist or the Album title are not displayed you can simply type these in and click OK. This will often be enough to group the album.
    If you place a checkmark against the blank boxes and apply changes then you will clear those fields so you should only do this if that is the effect you want. Putting a checkmark next to an empty (representing different values) *Track No.* box, for example, will just clear the all the track numbers which is very rarely useful.
    Adding then removing extra text is for a specific problem where despite all common values being identical across the tracks of the album iTunes seems to "remember" that it should see two albums. A typical example would be when an album originally listed as *Album CD1* & *Album CD2* is given disc numbers X of Y and then has the Album name changed to Album. I've seen iTunes merge all but one track into the new album, but insist on listing one remaining track separately, despite both albums having the same title. In this case I've found overtyping the album title again has no effect whereas changing it to AlbumX and then back to Album does what I was trying to achieve in the first place.
    Don't forget that even properly organsied albums may still break up if you don't chose an album-friendly view. Sorting on the track name or track number columns can be useful in some circumstances but in general I revert to Album by Artist when browsing through my library.
    tt2

  • How do you set up multiple accounts in itunes so phones don't automatically sync each others data ?

    How do you set up multiple itunes accounts to prevent multiple phones from sharing contact data?

    To add to Rod's answer, I have been blogging to explain more in detail the work flows for Question and Score slides, and some tweaking possibilities in these articles:
    http://lilybiri.posterous.com/question-question-slides-in-captivate
    http://lilybiri.posterous.com/question-question-slides-part-2
    Lilybiri

  • How do you get iPhone 5 to connect to iMac through bluetooth?

    How do you get iPhone 5 to connect to iMac through bluetooth?
    I know the basic steps, but all I get is pairing unsuccessful. I'm using an older bluetooth, would that make a difference? I got connected once with a Motorola bluetooth, but can't reconnect. TIA!

    Try the Bluetooth Troubleshooting steps here:
    http://support.apple.com/kb/TS2756
    Note that you need to have Personal Hotspot set up with your carrier and on your iPhone before you can connect the computer.
    Regards.

  • How do you detect url redirects when connecting to a URL

    how do you detect url redirects when connecting to a URL?
    Thanks in advance
    stev

    Hai
    (i) If it a jsp we can get the URL by request object.
    Like
    String url = request.getHeader("Referer");
    u can do it in Servlet aslo by request object variable.
    If this explanation is not ok, Explain ur doubt in more briefed Manner

  • How do you count the multiple columns of a field in a table

    How do you count the multiple columns of a field in a table

    Hi,
    4396bf34-e890-4202-a6b0-4e08c9ff0e89 wrote:
    How do you count the multiple columns of a field in a table
    Whenever you have a problem, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002
    "Field" isn't a standard database term.  Some people say "field" when they mean "column", but I don't think that's what you mean ("How do you count the multiple columns of a column ..").  Do you want to know how many times a column is used (as opposed to NULL), or the number of different values in a column?  You really need to show what you want.

  • How do you respond to multiple recipients on a text message?  I can only respond to the sender.

    How do you respond to multiple recipients on a text message on the samsung brighside?  I can only respond to the sender of the text.

    Being that the Brightside is a basic phone, it might not be capable of responding to a group.  The option does seem to be there, though - pg.  48 of the user manual:
    While viewing a message touch to display available options:
    • Reply w. Copy: Reply to the sender, plus other recipients if desired,
    and include a copy of the original message.
    Using the "More" option, you can apparently add recipients, or reply to more than one.

  • How to provide access to multiple users connected to a Dumb switch? (multi-auth/multi-domain)

    Good morning everybody,
    I am writing on behalf of not being able to implement a desired outcome in our company network. In fact the situation is as follows:
    What I want to do is to be able to authenticate users (802.1x authentication) in our company radius server and authorize them access by having a dynamic VLAN assignment in a multi-user environment on one and the same port of a Cisco 2960 switch. So far, the authentication and authorization has been working completely smoothly (there are no problems with itself). The concept involves the configuration of both DATA and VOICE VLANs as I there is also phone authentication implemented. In order to simulate this environment I introduce a Dumb switch connected to my Cisco 2960 Catalyst.
    What I have successfully managed to get to work so far is this:
    1) On one switch port I have tried the “authentication host-mode multi-domain” and it worked perfectly for a PC behind a telephone, or with one PC connected to a the dumb switch + the telephone connected to another port of the dumb switch. Logically it is the same situation as there is a separation in two domains – DATA and VOICE. Bellow is an output from show authentication sessions for this scenario.
    Interface  MAC Address     Method   Domain   Status         Session ID          
    Fa0/23     0021.9b62.b79b  dot1x    DATA     Authz Success  C0A8FF69000000F3008E (user1)
    Fa0/23     0015.655c.b912  dot1x    VOICE    Authz Success  C0A8FF69000000F9009F (phone)
    2) On the other hand, when I try the same scenario with the “authentication host-mode multi-auth”, the switch still separates the traffic in two domains and is able to authenticate all users, AS LONG AS they are in the same VLAN.
    show authentication sessions:
    Interface  MAC Address     Method   Domain   Status         Session ID          
    Fa0/23     0021.9b62.b79b  dot1x    DATA     Authz Success  C0A8FF69000000F3008E (user1)
    Fa0/23     b888.e3eb.ebac   dot1x    DATA     Authz Success  C0A8FF69000000F8008C (user2)
    Fa0/23     0015.655c.b912  dot1x    VOICE    Authz Success  C0A8FF69000000F9009F (phone)
    However, I cannot succeed authentication of many users from DIFFERENT VLANs, neither in multi-auth nor in multi-domain modes.
    What I want to get is an output like this:
    Interface  MAC Address     Method   Domain   Status         Session ID          
    Fa0/23     0021.9b62.b79b  dot1x    DATA     Authz Success  C0A8FF69000000F3008E (user1)
    Fa0/23     b888.e3eb.ebac dot1x    DATA     Authz Success  C0A8FF69000000F8008C (user2)
    Fa0/23     0015.655c.b912  dot1x    VOICE    Authz Success  C0A8FF69000000F9009F (phone)
    I want the switch to authenticate the users anytime they connect to itself and for them to have an instant access to the network. (I tell this because I tried scenario 1) with multi-domain mode and authentication violation replace, and it worked but, two users never had access to the “Internet” simultaneously!!!
    The configuration of the interface connected to the Dumb switch is as follows.
    interface FastEthernet0/x                                                      
     description Connection to DUMBswitch                                            
     switchport mode access                                                         
     switchport voice vlan XXX                                                      
     switchport port-security maximum 10                                            
     switchport port-security                                                       
     switchport port-security violation protect                                     
     authentication host-mode multi-auth                                            
     authentication priority dot1x                                                  
     authentication port-control auto                                               
     authentication timer reauthenticate 4000                                       
     authentication violation replace                                               
     dot1x pae authenticator                                                        
     dot1x timeout tx-period 10                                                     
     spanning-tree portfast                                                         
    The way I see it is explained in the following steps:
    - PC1 connects to the Dumb switch. This causes the Cisco switch to authenticate user1. This creates an auth. session with its MAC address linked to a domain DATA.
    - When PC2 connects to the Dumb switch, this causes the violation replace which replaces the recent authenticated MAC address with the MAC of PC2. I would like it once authenticated to appear in the authentication sessions with a link to a new DATA domain linked to the VLAN assigned from the RADIUS server.
    Is this possible? I think (in theory) this is the only way to provide authenticated access to multiple users connecting through Dumb switch to the network.
    Has anybody ever succeeded in such a configuration example and if yes, I would be love to get some help in doing so?
    Thank you
    Stoimen Hristov

    Hi Stoimen,
    I have done a setup similar to yours with the only exception being VLAN assignment. When I used dACLs only, it makes things somewhat easier as the VLAN no longer matters. Remember that the switchport is in access mode and will only allow a single VLAN across it (with the exception of the voice VLAN). I think that is the real cause of your problem.
    From what I can see, you have 2 options available to you:
    1) Use dACLs instead of VLAN assignment. This means that an access list will be downloaded from the radius server straight to the authenticated user's session. I have tested this and it works perfectly. Just Google Cisco IBNS quick reference guide and look for the section that deals with Low Impact mode.
    2) Get rid of the dumb switches and use managed switches throughout your network. Dumb switches will always be a point of weakness in your network because they have no intelligence to do advanced security features like port security, 802.1x, DHCP snooping, etc.
    Hopefully someone else will chime in with another option.
    Xavier

  • How do you keep iPhone charged while connected to carplay

    How do you keep iPhone charged in the car while it is connected to the cable for CARPLAY?

    The next time you connect your iPad to your laptop, click on your iPad under Devices and then click on the Apps tab on top. Once it opens and lists all your apps in iTunes on the left (both iPad and iPhone ), simply uncheck the boxes next to the iPhone apps you wish to leave off from future syncs. They will still be in iTunes and available for your iPhone, but won't be synced to your iPad. Click on Apply.

  • How do you break the cycles in "connect by nocycles" query.

    I looked at the documentation of the oracle hierarchical queries to see if there is a deterministic way of breaking the cycles.
    http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/queries003.htm
    I understand that plain connect by query fails if there are cycles in the data, this can be over come by using the nocycles clause. But how does oracle handle the cycles if it finds one, is there a deterministic way of breaking the cycles, or is random? If it is deterministic, Is there a sophisticated algorithm you use to break the cycles?
    My sample query is as shown below:
    SELECT ename "Employee", CONNECT_BY_ISCYCLE "Cycle",
    LEVEL, SYS_CONNECT_BY_PATH(ename, ’/’) "Path"
    FROM scott.emp
    WHERE level <= 3 AND deptno = 10
    START WITH ename = ’KING’
    CONNECT BY NOCYCLE PRIOR empno = mgr AND LEVEL <= 4;
    Thanks,
    Paul

    Hi, Paul,
    849708 wrote:
    Thanks for the very detailed explanation Frank.
    It is interesting that the cycles are not broken at the time of the creation of the hierarchies, but at the time of the traversal.The relationship is only defined in the CONNECT BY clause of a query. When you create and populate tables, you don't indicate in any way that certain columns will be used in a CONNECT BY clause. You're free to use any columns you want when you write the query. You can use different columns and different relationships in different queries.
    This leads me to one more question:
    Lets say there are multiple routes from a given ancestor node to a decedent node, what would be the value of PATH pseudo column. Does it consider the shortest path or the longest path? If the two routes are of the same length? which would be used?The same node can appear more than once as a descendant of the same ancestor. All paths that satisfy the CONNECT BY clause (and the WHERE clause, if there is one) will be included. For example, the following query shows how Prince William is related to one of his ancestors, Anna Sophie (1700-1780):
    SELECT     LEVEL
    ,     SYS_CONNECT_BY_PATH (name, ' \ ')     AS path
    FROM     royal
    WHERE     name     = 'Anna Sophie of Schwarzburg-Rudolstadt'
    START WITH     name     = 'William of Wales'
    CONNECT BY     id     IN (PRIOR mother_id, PRIOR father_id)
    ;The genealogy table I used showed 8 different line of descent, ranging from 10 to 12 generations:
    LEVEL PATH
       11  \ William of Wales \ Charles, Prince of Wales \ Elizabeth II \ George
           VI \ George V \ Edward VII \ Victoria \ Victoria of Saxe-Coburg-Saalf
          eld \ Franz Frederick of Saxe-Coburg-Saalfeld \ Ernst Frederick of Sax
          e-Coburg-Saalfeld \ Anna Sophie of Schwarzburg-Rudolstadt
       12  \ William of Wales \ Charles, Prince of Wales \ Elizabeth II \ George
           VI \ George V \ Edward VII \ Albert of Saxe-Coburg and Gotha \ Louise
           of Saxe-Gotha-Altenburg \ Louise Charlotte of Mecklenburg \ Frederick
           Francis I of Mecklenburg \ Charlotte Sophie of Saxe-Coburg-Saalfeld \
           Anna Sophie of Schwarzburg-Rudolstadt
       11  \ William of Wales \ Charles, Prince of Wales \ Elizabeth II \ George
           VI \ George V \ Edward VII \ Albert of Saxe-Coburg and Gotha \ Ernest
           I, Duke of Saxe-Coburg and Gotha \ Franz Frederick of Saxe-Coburg-Saa
          lfeld \ Ernst Frederick of Saxe-Coburg-Saalfeld \ Anna Sophie of Schwa
          rzburg-Rudolstadt
       11  \ William of Wales \ Charles, Prince of Wales \ Elizabeth II \ George
           VI \ George V \ Alexandra of Denmark \ Louise of Hesse-Kassel \ Louis
          e Charlotte of Denmark \ Sophia Frederica of Mechlenburg-Schw. \ Charl
          otte Sophie of Saxe-Coburg-Saalfeld \ Anna Sophie of Schwarzburg-Rudol
          stadt
       11  \ William of Wales \ Charles, Prince of Wales \ Philip, Duke of Edinb
          urgh \ Alice of Battenberg \ Montbatten, Victoria \ Alice, Duchess of
          Hesse \ Victoria \ Victoria of Saxe-Coburg-Saalfeld \ Franz Frederick
          of Saxe-Coburg-Saalfeld \ Ernst Frederick of Saxe-Coburg-Saalfeld \ An
          na Sophie of Schwarzburg-Rudolstadt
       12  \ William of Wales \ Charles, Prince of Wales \ Philip, Duke of Edinb
          urgh \ Alice of Battenberg \ Montbatten, Victoria \ Alice, Duchess of
          Hesse \ Albert of Saxe-Coburg and Gotha \ Louise of Saxe-Gotha-Altenbu
          rg \ Louise Charlotte of Mecklenburg \ Frederick Francis I of Mecklenb
          urg \ Charlotte Sophie of Saxe-Coburg-Saalfeld \ Anna Sophie of Schwar
          zburg-Rudolstadt
       11  \ William of Wales \ Charles, Prince of Wales \ Philip, Duke of Edinb
          urgh \ Alice of Battenberg \ Montbatten, Victoria \ Alice, Duchess of
          Hesse \ Albert of Saxe-Coburg and Gotha \ Ernest I, Duke of Saxe-Cobur
          g and Gotha \ Franz Frederick of Saxe-Coburg-Saalfeld \ Ernst Frederic
          k of Saxe-Coburg-Saalfeld \ Anna Sophie of Schwarzburg-Rudolstadt
       10  \ William of Wales \ Charles, Prince of Wales \ Philip, Duke of Edinb
          urgh \ Andrew of Greece and Denmark \ George I of Greece \ Louise of H
          esse-Kassel \ Louise Charlotte of Denmark \ Sophia Frederica of Mechle
          nburg-Schw. \ Charlotte Sophie of Saxe-Coburg-Saalfeld \ Anna Sophie o
          f Schwarzburg-RudolstadtBy the way, SYS_CONNECT_BY_PATH is a function, not a pseudo-column. Pseudo-columns don't take arguments.
    I could have tested all this myself, but currently I do not have access to the database. Is there a publicly available database (through ssh) which I can use in the mean time :)You can download Oracle Express Edition.
    http://www.oracle.com/technetwork/database/express-edition/downloads/index.html
    It's free if all you're using it for is learning.
    You can also get a free workspace in an Oracle-hosted database at apex.oracle.com.
    Edited by: Frank Kulash on Apr 4, 2011 6:51 PM

  • How to get active monitor-Multiple monitors connected to a single machine.

    Hi,
    How to get the id of active graphic device, in case of multiple graphic devices connected to a single machine(Multi-headed display/ multi headed nodes) using Swing.
    Prashanth.

    Ah, youre actually asking different things.
    In your topic title, you say youre running separate instances
    In your body text, you say you are under different user/schema
    So tell me, do you have more than one database or not? How many entries in your TNS file?
    I would say, for "multiple database instances"
    SELECT
      a.id, b.id
    FROM
      tableA a
      INNER JOIN
      tableB@OTHER_DATABASE_LINK_NAME b  <--NOTE!
      USING(id)And of course you will have to look up CREATE PUBLIC DATABASE LINK sql..
    Message was edited by:
    charred

  • How can you hook up multiple camcorders for video shoot?

    I'm making plans for my wedding and I was interested in recording it with stationary camcorders and my Macbook Pro's webcam of the event. I've hooked up my camcorder before as a additional webcam, but I have't recorded from multiple camera's before. This is importabt because I was also thinking of streaming the video from all 3 cameras online so friends and family could watch the event from out-of-town.
    I was thinking I could use my Final Cut Pro software to bring the Camcorder footage in using firewire, but I'm not sure about the computers webcam.
      I would really like any opinions and suggestions that don't require additonal purchases.
    Any past experiences would be appreciated.

    Hello JamieLG. Welcome to the Apple Discussions!
    First, let's double-check your AirPort Express Base Station's (AX) settings...
    AirPort Express Base Station Setup (AX) w/High-Speed Cable Modem
    Setup the AX
    Connect to the AX's wireless network, and then, using the AirPort Admin Utility, check these settings:
    AirPort tab
    o Base Station Name: <whatever you wish or use the default>
    o AirPort Network Name: <whatever you wish or use the default>
    o Create a closed network (unchecked)
    o Wireless Security: <your current wireless security setting: None, WEP, or WPA>
    o Channel: Automatic
    o Mode: 802.11b/g Compatible
    Internet tab
    o Connect Using: Ethernet
    o Configure: Using DHCP
    o WAN Ethernet Port: Automatic
    Network tab
    o Distribute IP addresses (checked)
    o Share a single IP address (using DHCP & NAT) (enabled)
    If you have wireless security enabled, which type is it: WEP, WPA, or WPA2?

  • How do you select/move multiple clips from one timeline to another?

    Has to do with combining multiple edls from Avid - required due to an issue with duplicate reel names in the original Arri footage. I can move them one at a time, but it is very tedious. Is there a way to select multiple clips and move them together?

    Actually discovered the magic of the shift key.
    IRCP Beauty doesn't recognize multiple timelines in a session, so first you have to at least get the footage on multiple tracks in the same timeline. Shift + drag on the track will allow you to move it to another timeline. Also Shift + drag on the center of the first clip in a sequence will slide the entire sequence down - which is how timelines end up getthing offset all the time. Also, if there are multiple tracks in a timeline and some are locked and some aren't, Shift + drag on a clip will slide ALL UNLOCKED tracks in the timeline.
    Finally, Shift + click on either in or out marker moves both points up or down the timeline.

  • How do you keep the same URL connection connected continuously?

    I am trying to extract information from a web page, but it puts a cust_id in the middle of the URL. It generates the cust_id randomly everytime you use the site. I connect to the initial URL to find the cust_id, I substring that to the new URL and then make a new connection to extract the information, but the web page gives me an error saying that it doesn't recognise the cust_id. As if it was a new connection with the wrong cust_id.
    How can I keep the first connection open and with the same cust_id information and then jump to another web page but using the initial connection. Using IE6 I can just cut and paste the second URL and get to the page, but with my java application it doesn?t work. Please have a look at my code and let me know if I am doing anything wrong.
    URL inputURL;
         String inputLine;
         URLConnection connection;
         String page = "";
         int x;
         String cust_id1 = "";
         String cust_id2 = "";
         String site;
         File outputFile = new File("web.txt");
         FileWriter out = new FileWriter(outputFile);
       try
         inputURL = new URL("http://www-ets.woolworths.com.au/ets/owa/login?topage=search");
         connection = inputURL.openConnection();
         BufferedReader inputStream = new BufferedReader(new InputStreamReader(connection.getInputStream()));
         while ((inputLine = inputStream.readLine()) != null)
              page = page + inputLine;
              System.out.println(inputLine);
              x = inputLine.indexOf("cust_id=");
              if (x != -1)
              cust_id1 = inputLine.substring(x, x + 14);
              PrintWriter file = new PrintWriter(new FileOutputStream("web.txt"));
              out.write(page);
              out.close();
              System.out.println("1st time successful");
              System.out.println(cust_id1);
              //inputStream.close();
              //extracted the customer id, now able to search for the product
              //test for milk
         site = "http://www-ets.woolworths.com.au/ets/owa/items?search_pattern=milk&";
         site = site + cust_id1;
         site = site + "&imode=search&search_option=";
         System.out.println(site);     
         inputURL = new URL(site);
         BufferedReader inagain = new BufferedReader(new InputStreamReader(inputURL.openStream()));
         //tried the connection way
         //connection = inputURL.openConnection();          
         //BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
         while ((inputLine = inagain.readLine()) != null)
              //System.out.println(inputLine);          
              x = inputLine.indexOf("cust_id=");
              if (x != -1)
              cust_id2 = inputLine.substring(x, x + 14);
              System.out.println(cust_id1);
              System.out.println(cust_id2);
              System.out.println("2nd time completed");
              inputStream.close();
       catch(ArrayIndexOutOfBoundsException obe)
                System.out.println("Usage: FetchURL url");
       catch(IOException ioe)
                System.out.println("IO Exception");

    Please have a quick look at my code and see if I am doing anything wrong. I havent been able to set the correct cookies and the output html page comes up with an error saying that it could not retrieve my request. This time there is no mention of invalid cust_id.
              try
                   URL inputURL = new URL("http://www-ets.woolworths.com.au/ets/owa/login?topage=search");
                   connection = inputURL.openConnection();
                   System.out.println("filename = " + inputURL.getFile());
                   BufferedReader inputStream = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                   while ((inputLine = inputStream.readLine()) != null)
                        //System.out.println(inputLine);
                        page = page + inputLine;     
                        x = inputLine.indexOf("cust_id=");
                        if (x != -1)
                             cust_id = inputLine.substring(x + 8, x + 14);
                   out.write(page);
                   out.close();
                   System.out.println("extracted cust_id: " + cust_id);
                   for (int i = 1; i <= 30; ++i)
                        System.out.println("    Header " + i + ":  " + connection.getHeaderFieldKey(i) + ": " + connection.getHeaderField(i));
                        header = header + connection.getHeaderFieldKey(i);
                        header = header + ": ";
                        header = header + connection.getHeaderField(i);
                   outcookie.write(header);
                   outcookie.close();           
                   inputStream.close();          
                   //extracted the customer id, now able to search for the product
                   //test for milk
                   String url2 = "http://www-ets.woolworths.com.au/ets/owa/items";
                   //String url2 = "http://www-ets.woolworths.com.au/ets/owa/login?topage=search";
                   inputURL = new URL(url2);     
                   connection = inputURL.openConnection();     
                   connection.setDoOutput(true);
                   //connection.setUseCaches(false);
                   System.out.println("filename = " + inputURL.getFile());
                   String date = "; expires=Mon, 28 Jan 2002 02:53:17GMT; path/;";     
                   String date1 = "expires=Sun, 31 Dec 1989 14:00:00 GMT; path/;";
                   connection.setRequestProperty("cookie", "qwc=" + cust_id + date);
                   connection.setRequestProperty("cookie", "cust_id=" + cust_id + "; path=/;");
                   connection.setRequestProperty("cookie", "cd=2%40142%40%40%40%40N%40; path=/;");
                   connection.setRequestProperty("cookie", "state=NSW; path=/;");
                   connection.setRequestProperty("cookie", "dsd=1; path=/;");
                   connection.setRequestProperty("cookie", "sb1=0%2A%2D645746%2D0%2A; path=/;");
                   connection.setRequestProperty("cookie", "sb2=0; " + date1);
                   connection.setRequestProperty("cookie", "sb3=0; " + date1);
                   connection.setRequestProperty("cookie", "sb4=0; " + date1);
                   connection.setRequestProperty("cookie", "sb5=0; " + date1);
                   connection.setRequestProperty("cookie", "sb6=0; " + date1);
                   connection.setRequestProperty("cookie", "sb7=0; " + date1);
                   connection.setRequestProperty("cookie", "sb8=0; " + date1);
                   connection.setRequestProperty("cookie", "sb9=0; " + date1);
                   connection.setRequestProperty("cookie", "sb10=0; " + date1);
                   connection.setRequestProperty("cookie", "sbn=; path=/");
                   connection.setRequestProperty("cookie", "search=milk; " + date1);               
                   //connection.setRequestProperty("Content-type", "application/octet-stram");
                   //connection.setRequestProperty("Content-type", "application/x-www-form-urlencoded");
                   //String parms = "?search_pattern=" + URLEncoder.encode("milk") + "&cust_id=";
                   //parms = parms + URLEncoder.encode(cust_id);
                   //parms = parms + "&imode=" + URLEncoder.encode("search") + "&search_option=";
                   //System.out.println("parms : " + parms);
                   String parms = "?search_pattern=milk&cust_id=";
                   parms = parms + cust_id;
                   parms = parms + "&imode=search&search_option=";
                   System.out.println("parms : " + parms);
                   PrintWriter outStream = new PrintWriter(connection.getOutputStream());
                   outStream.println("parms");
                   outStream.close();               
                   BufferedReader inputStream1 = new BufferedReader(new InputStreamReader(connection.getInputStream()));     
                   //BufferedReader inagain = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                   while ((inputLine = inputStream1.readLine()) != null)
                        //System.out.println(inputLine);
                        page2 = page2 + inputLine;
                        x = inputLine.indexOf("cust_id=");
                        if (x != -1)
                             cust_id2 = inputLine.substring(x + 8, x + 14);
                   out2.write(page2);
                   out2.close();
                   System.out.println("2nd attempt cust_id" + cust_id2);
                   for (int i = 1; i <= 30; ++i)
                        System.out.println("    Header " + i + ":  " + connection.getHeaderFieldKey(i) + ": " + connection.getHeaderField(i));
                        header2 = header2 + connection.getHeaderFieldKey(i);
                        header2 = header2 + ": ";
                        header2 = header2 + connection.getHeaderField(i);
                   outcookie2.write(header2);
                   outcookie2.close();      
                   inputStream.close();
              }The original web page to get the cookie is
    http://www-ets.woolworths.com.au/ets/owa/login?topage=search
    Enter a search product eg milk and that is the second page I am trying to extract.
    You will notice in the middle of the url is cust_id.
    Am I going about this 2 pages completely wrong?

Maybe you are looking for