I'm wondering..why does the outermost exception always catch the error?

hi
why do sometimes (or everytime) i create a code which looks something like this..
try{
    try{
          //some error here
    } catch (Exception e){
           System.out.println("got it here: " + e.getMessage();
}catch (Exception e){
      System.out.println("got it here instead: " + e.getMessage();
}it's always the outermost catch block caughts the error. In this example the line got it here instead: some error messageis displayed.
I really thought for sure the inner exception is the one who should catch the error first, right? Furthermore they both catch the same thing (Exception).
Any information is greatly appreciated. thanks

No, you're wrong.I'm relieved to hear that. But why does my code always does what I mentioned above? here's my code (it's a partial code, actually. it takes too many lines to put all the codes here):
void generatePIN(String Date){
          char currentCodeChar;
          int seeder=0, serialNumber=0000000;
          int currentNumberInt=0, nextNumber=0, currentCodeInt=0;
          String voucherSerial=null, PINnumber=null, currentNumber=null, currentCode=null, nextCode=null, currentSerial=null, nextSerial=null;
          int PIN1=0,PIN2=0;
          String query=null;
          PreparedStatement ps=null;
          ResultSet rs=null;
          try{
               //this portion here is used for proper seeding random number
               SecureRandom sr1 = SecureRandom.getInstance("SHA1PRNG");
               seeder=sr1.nextInt();
               if (seeder<0){
                    seeder=seeder*-1;
          }catch (Exception e){
               System.out.println(e.getMessage());
               System.exit(1);
          random = new Random(seeder);
          PIN1 = random.nextInt(89999999)+10000000;
          PIN2 = random.nextInt(89999999)+10000000;
          PINnumber = "" + PIN1 + PIN2;
          System.out.println("PIN number: " + PINnumber);
          //check serial number first before storing the pin & serial number in database
          //if serial number exist, regenerate the serial number
          try{
               try{
               query = "select * from data1";
               ps = con.prepareStatement(query);     
               rs = ps.executeQuery();
                         while (rs.next()){
                         currentSerial = rs.getString("SerialNo");
               }catch (SQLException ex){
                    System.out.println("error here?" + ex.getMessage());
               while (currentNumberInt<=9999999){
                    currentNumberInt++;                    
          }catch (Exception e){
               JOptionPane.showMessageDialog(null,"Database error 1: " + e.getMessage());
               return;
     }the database is empty. hence it returns an error when i tried getting some data from it. but i expected the error message should be:
error here? some error message..instead of the
Database error 1: some error message pop-up being displayed.
Did i make any mistake in my code? I've spent hours on this..
thanks for helping

Similar Messages

  • Why does the iphone 5 always display the wrong time

    why does the iphone 5 always display the wrong time

    I had similar problem. My iPhone was always about 3 minutes faster than the correct time here in the UK which I found to be very irritating. It just came to a head because here in the UK we have just changed from British Summer Time back to standard GMT. This actually worked automatically except that the iPhone time still showed it to be about 3 minutes faster than GMT. However I have now cured the problem (almost) by going to
         Settings/General/ Date & Time/ and then selected the "Set Automatically" button.
    The clock then immediately jumped back 3 minutes and now the iPhone time is only about 10 seconds slow which is good enough for me.

  • I cannot send an email from my iPad 2? No problem receiving, why does this happen? Have tried the suggestions for setting up email and after doing the sync mail through iTunes receiving worked great but still cannot send? Any help would be great

    I cannot send an email from my iPad 2? No problem receiving, why does this happen? Have tried the suggestions for setting up email and after doing the sync mail through iTunes receiving worked great but still cannot send? Any help would be great!

    The fact that you can receive means you have a valid e mail address, and have established the connection to the incoming server, so all of that works.  Since the send does not work, that means your outgoing server is rejecting whatever settings you used formthe outgoing set up.  Try them again. 
    Google your particular isp, and ipad and many times you will find the exact settings needed for your isp.  Or tell us here, and soneone else may be on the same isp.  Some mail services need you to change a port, or have a unique name for the outgoing server.  
    Kep trying.

  • While watching an iTunes movie from my Apple TV, why does my movie stop playing at the 1 hour mark?  I'm assuming I have a setting causing this to happen, but I have no idea what setting needs to be changed.  Can someone help me?

    While watching an iTunes movie from my Apple TV, why does my movie stop playing at the 1 hour mark?  I'm assuming I have a setting causing this to happen, but I have no idea what setting needs to be changed.  Can someone help me?

    It's right at an hour (consistently), but the computer goes to sleep prior to that. It's as if iTunes goes to sleep. Also, it wasn't always this way. Originally, the movies played through without interruption. At some point, I guess a setting was changed, and now I only get an hour. Also. My energy settings are set to go to sleep at 10 minutes.

  • Why does my iPhone 4GS bounce of the TV

    Why does my iPhone 4S bounce of the TV (not flatscreen, old thick Philips) when I put the iPhone on top of it? It happens after some time, perhaps 20 minutes. The phone bounces of the TV and lands on the floor. The TV is off!

    Hi,
    That sounds like attention seeking behaviour.
    Step over it and ignore the antics.
    When it behaves in the fashion you expect it is OK to pick it up and follow the normal nurturing you use.
    If you do respond to it you will soon find yourself planning a zip line from your upstairs bedroom to the kitchen, coupled with a refusal to get in your pocket when you are ready to leave the house.
    7:32 PM      Thursday; June 14, 2012
      iMac 2.5Ghz 5i 2011 (Lion 10.7.2)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • Why does final cut x not recognize the sharp PN- K321 monitor ( European version ) as output video monitor and premiere it? Working with two cinema display and PN- K321 and I can not preview the output video at 4K for DisplayPort, whereas with premie

    Why does final cut x not recognize the sharp PN- K321 monitor ( European version ) as output video monitor, and premiere yes?
    Working with two cinema display and PN- K321 and I can not preview the output video at 4K by DisplayPort, whereas with premiere and after effects I have no problems

    Look, you can build an HD DVD with an SD movie, just as you can build an SD DVD with an HD movie. This is not a bug, it is most likely user error. Apple will not be addressing it.
    Just start over, and ensure you are building an SD DVD by bringing up the inspector for the disc (click on the background in the Graphical tab).
    Make sure SD DVD is selected:
    (If you do the same thing on your ill fated project, you'll see that HD DVD is selected)
    Build your DVD and you'll be fine.
    Patrick
    P.S. You will need to google HD DVD and Blu-Ray if you want to understand the difference between the formats. The reason that DVDSP included HD DVD was that its format was similar to SD DVD's. Blu-Ray is something else entirely.

  • Why does Apple not give a list of error messages and possible solutions? I have the (-54) error continually that has suddenly appeared and cannot find a solution, even though other users seem to have the same problem.

    Why does Apple not give a list of error messages and possible solutions? I have the (-54) error continually that has suddenly appeared and cannot find a solution, even though other users seem to have the same problem.

    This is a user to user forum.  Apple isn't here and won't answer you.  You need to contact Apple directly.  You can use the Contact button at the bottom of the screen.

  • When I click on a website in my reading list, why does top sites open rather than the site I've clicked on?

    When I click on a website in my Reader list in Safari, why does Top Sites open rather than the website I've clicked on?

    Go step by step and test.
    Reset Safari.
    Click Safari in the menu bar.
    From the drop down select "Reset Safari".
    Click "Reset".
    Delete Cookies
    Safari > Preferences > Privacy > Cookies and other website data:
    Click “Remove All Website Data”.
    Empty Caches
    Safari > Preference > Advanced
    Checkmark the box for "Show Develop menu in menu bar".
    Develop menu will appear in the Safari menu bar.
    Click Develop and select "Empty Caches" from the dropdown.
    Turn off Extensions if any, and launch Safari.
    Safari > Preferences > Extensions

  • While trying to instal Mountain Lion OS on my macbook pro, I got the error message that my HD was damaged and it reverted to my Lion OS. Why does this happen? I bought the OS online through the app store

    While trying to instal Mountain Lion OS on my macbook pro, I got the error message that my HD was damaged and it reverted to my Lion OS. Why does this happen? I bought the OS online through the app store.

    The Mountain Lion installer looks at your internal drive to make certain that it's error-free before continuing installation. You should have an application named "Install OS X Mountain Lion.app" in your Applications folder now so you shouldn't have to download it again. Do this...
    Boot to your Lion recovery partition by holding down both the Command and the R keys while booting. Open Disk Utility from the Recovery partition and select your hard drive (usually named "Macintosh HD" unless you've renamed it) and click on Verify Disk. If you come up with any errors, click on Repair Disk. At the end of the cycle you will get a message that the disk was successfully repaired or a message that the hard drive could not be repaired.
    If you're able to repair the disk, just reboot as normal and open the "Install OS X Mountain Lion.app" and the installation will proceed. If Disk Utility was unable to repair the disk, you need to get to your local Apple Store as soon as possible so that they can see if the disk is salvageable or beyond repair.
    Good luck,
    Clinton

  • Why does a bar sometimes appear below the Firefox icon in my tray?

    Why does a thick bar appear under the Firefox icon in my tray. I cannot correlate its appearance to anything I'm doing online.

    Try to reinstall Firefox.
    Download a new copy of the Firefox application and save the disk image file to the desktop
    *Firefox 32.0.1: https://www.mozilla.org/en-US/firefox/all.html
    *Trash the current Firefox application (open the Applications folder in the Finder and drag the Firefox application to the Trash) to do a clean (re)install
    *Install the new version that you have downloaded
    *https://support.mozilla.org/kb/Installing+Firefox+on+Mac
    Your personal data is stored elsewhere in the Firefox profile folder, so you won't lose your bookmarks and other personal data when you uninstall and (re)install Firefox.
    *http://kb.mozillazine.org/Profile_folder_-_Firefox

  • Why does Adobe Premiere CC lockup on the launch?

    Why does Adobe Premiere CC lockup on the launch?

    Without system information and otehr details nobody can even guess.
    Mylenium

  • Why does my macbook pro stop loading the webpage every time i try to access netflix or youtube?

    Why does my macbook pro stop loading the webpage (in safari) every time I try to access netflix or youtube?

    Back up all data before proceeding.
    This procedure will unlock all your user files (not system files) and reset their ownership, permissions, and access controls to the default. If you've intentionally set special values for those attributes on any of your files, they will be reverted. In that case, either stop here, or be prepared to recreate the settings if necessary. Do so only after verifying that those settings didn't cause the problem. If none of this is meaningful to you, you don't need to worry about it, but you do need to follow the instructions below.
    Step 1
    If you have more than one user, and the one in question is not an administrator, then go to Step 2.
    Triple-click anywhere in the following line on this page to select it:
    sudo find ~ $TMPDIR.. -exec chflags -h nouchg,nouappnd,noschg,nosappnd {} + -exec chown -h $UID {} + -exec chmod +rw {} + -exec chmod -h -N {} + -type d -exec chmod -h +x {} + 2>&-
    Copy the selected text to the Clipboard by pressing the key combination command-C.
    Launch the built-in Terminal application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Terminal in the icon grid.
    Paste into the Terminal window by pressing command-V. I've tested these instructions only with the Safari web browser. If you use another browser, you may have to press the return key after pasting.
    You'll be prompted for your login password, which won't be displayed when you type it. Type carefully and then press return. You may get a one-time warning to be careful. If you don’t have a login password, you’ll need to set one before you can run the command. If you see a message that your username "is not in the sudoers file," then you're not logged in as an administrator.
    The command may take several minutes to run, depending on how many files you have. Wait for a new line ending in a dollar sign ($) to appear, then quit Terminal.
    Step 2 (optional)
    Take this step only if you have trouble with Step 1, if you prefer not to take it, or if it doesn't solve the problem.
    Start up in Recovery mode. When the OS X Utilities screen appears, select
              Utilities ▹ Terminal
    from the menu bar. A Terminal window will open. In that window, type this:
    res
    Press the tab key. The partial command you typed will automatically be completed to this:
    resetpassword
    Press return. A Reset Password window will open. You’re not going to reset a password.
    Select your startup volume ("Macintosh HD," unless you gave it a different name) if not already selected.
    Select your username from the menu labeled Select the user account if not already selected.
    Under Reset Home Directory Permissions and ACLs, click the Reset button.
    Select
               ▹ Restart
    from the menu bar.

  • Why does my site look nothing like the design and during testing once uploaded to the server?

    Why does my site look nothing like the design and during testing once uploaded to the server?,
    Im using Muse whichj crashes like you would not beleive, but after much perseverance I got a basic 4 page holding site together, I tested the site and it all looked fine, when I uploaded it to the server it looks nothing like the site I tested, to the point that even the background has changed colour and nothing is in the rite place.

    Hi John, Sure it's
    http://www.thezine.co.uk
    thanks
    it should be looking like this

  • Why does photoshop download pictures automatically off the internet that I don't want?

    why does photoshop download pictures automatically off the internet that I don't want?

    Where are the pictures coming from? I would more likely believe that your system has a virus than photoshop, but without more information, I could be misinterpreting your post.

  • Why does my iPhone 4 not have the panorama feature with the new iOS 6 ?

    Why does my iPhone 4 not have the panorama feature with the new iOS 6 ? Can someone please explain this to me. I was already excited about it.

    That was made available in iOS 5. To update, you may need to connect to iTunes

Maybe you are looking for

  • Link to Framemaker in RH8

    I just upgraded to Robohelp8 with the intention of linking to some of our Documentation Team's Framemaker7 files. I did not purchase the TC suite, since I would not be able to open the Documentation Team's FrameMaker7 files (TC2 uses FrameMaker8).  I

  • HT204365 Open PDF's with iBooks

    I want to open PDF's with iBooks. I am using Mavericks, so I drag and drop the files in the iBooks library and still opens with adobe. I also try the "open with" option and it says the file is damaged.

  • Chat System: ConnectException: Connection timed out: connect

    Hi There, I am developing a chat system as part of a University project. To explain what I have implemented: I have three java classes; 1. Chat Server class which is constantly listening for incoming socket connection on a particular socket: while (t

  • Sd CIN error

    while saving commercial invoice we get pop up menu saying"Print excise invoice in series group s2 using J1IP for billing document 00060000024" and on task bar we get "Document 0006000024 saved(no accounting document generated)" after that when we com

  • BEx Analyzer / authorizations / query search

    Hello everyone Today I have a problem with my authorizations for the the BEx Analyzer. The technical name of my InfoArea is VCOPA. I have a number of queries with the technical name VCOPA_MM001 / VCOPA_M01_X0001 / and so on. When I open the BEx analy