How to override exception

There is a class called DbCommon which implements basic database operations. One of it's method is called loadFromDb() which loads data from the database and set variables
to the database values. Like this:
//DbCommon.java
void loadFromDb() throws ObjectNotFoundException {
//Connect to database
rs = pstmt.executeQuery()
if (!rs.next())
throw new ObjectNotFoundException();
However, there is a problem: other classes that inherits from DbCommon throws different exceptions. for ex. there is a DbProjectManager inheris DbCommon, When it can't
find a specified project, it throws a ProjectNotFoundException, not ObjectNotFoundException. And a DbBugManager may throw a
BugNotFoundException.
So, how to through different exceptions without rewriting the code?
Thanks

Make ProjectNotFoundException et al. be subclasses of ObjectNotFoundException.

Similar Messages

  • How to override the create method invoked by a create form?

    Hello everyone, I'm using ADF Faces and have the next question:
    How can I override the create method which is invoked by a create form to preset an attribute in the new row (the preset value is not fixed, I have to send it to the method as a parameter as it is obtained using an EL expression)?
    In the ADF guide I read how to override a declarative method (Section 17.5.1 How to override a declarative method), but this explains how to do it with a method that is called by a button. I don't know how to do the same with a method which is called automatically when the page is loaded.
    I also tried overriding the view object's createRow() method to receive a parameter with the preset values but it didn't work, I believe that was because the declarative create method is not the same as the view object's createRow. This caused the form to display another row from the viewobject and not the newly created one (I also set the new row into STATUS_INITIALIZED after setting the attribute).
    Well, I hope my problem is clear enough for somebody to help me.
    Thank you!

    Hello,
    I'm not sure you can do it with standard generated Create Form.
    In your view object you'll need to create your own create method with parameters, publish it to client interface and invoke instead of standard generated create action in page definition.
    Rado

  • How to throw exception in run() method of Runnable?

    Hi, everyone:
    I want to know how to throw exception in run() method of interface Runnable. Since there is no throwable exception declared in run() method of interface Runnable in Java API specification.
    Thanks in advance,
    George

    Thanks, jfbriere.
    I must add though that if your run() methodis
    executed after a call to Thread.start(), then
    it is not a good choice to throw anyRuntimeException
    from the run() method.
    The reason is that the thrown exception won't be
    handled appropriately by a try-catch block.Why do you say that "the thrown exception won't be
    handled appropriately by a try-catch block"? Can you
    explain it in more detail?
    regards,
    George
    Because the other thread runs concurrently with and independently of the parent thread, there's no way you can write a try/catch that will handle the new thread's exception: try {
        myThread.start();
    catch (TheExceptionYouWantToThrowFromRun exc) {
        handle it
    do the next thing This won't work because the parent thread just continues on after myThread.start(). Start() doesn't throw the exception--run() does. And our parent thread here has lost touch with the child thread--it just moves on to "do the next thing."
    Now, you can do some exception handling with ThreadGroup and uncaughtException(), but make sure you understand why the above won't work, in case that was what you were planning to do.

  • Computer doesn't recognize administrator password.  How to override or reset?

    Computer doesn't recognize administrator password.  How to override or reset?

    You cannot override but you can chage it, the approach depends on the Mac OS X you are using.

  • How to add Exception handling in Oracle Business rules Function

    Hello,
    We use to have good number of business rules in our application. So we need to have some functions in BR Composite.
    Can some one let me know how to handle exception in Oracle business rules exception( Regular try catch will not compile)
    is there any way please let me know.
    Edited by: Network22 on Mar 25, 2013 10:21 AM

    Why aren't you using por_custom_pkg.custom_validate_req_line to add extra validations.
    Ensure that profile POR: Enable Requisition Line Customization is set to Yes if you were to use po_custom_pkg for Requisition line validations.
    OAF calls por_custom_pkg at various points depending upon the values in Profile Options:-
    POR: Enable Req Distribution Customization
    POR: Enable Req Header Customization
    POR: Enable Requisition Line Customization
    Thanks,
    Anil Passi

  • How to override confirmation fr sending sms? -urgent-

    I made an application that suppose to send an sms automatically. But it always prompts a confirmation question. How to override this? Thank you..

    This is a problem not only when sending to the few people without a data plan but for people roaming with their data connection disabled to control costs. Somehow, my iPhone can tell the other phone is an iPhone even with no data connection and tries to send an iMessage. It would be nice to be able to send a text message right away instead of waiting for the iMessage to fail or perhaps failing to notice that the "Delivered" notice did not appear.

  • HOW TO override/modify default PTG homepage?

    Hi:
    I want to know how to override default portal to go homepage. I've create my wireless app that is already well deployed in a container and already working in PTG. I want to know how to modify the default ptg home. I've removed all apps from ptg to the guests users and just give access to guest to my application. I need a simple default homepage and i need to remove the SETUP link that is always displayed in /PTG/RM page. Also, can anyone tell me how to create a simple url to access my wireless portal?
    for instance i have to write : portal.myorg.pt/ptg/rm and i would like to just hae to write : wire.morg.pt
    How can i achieve this?
    Thanks
    Joao

    I'm using a beta of 10G at the moment. What I did is change the oracle logo (logo.gif) with our own company's logo (http://host:port/ptg/images/logo.gif) (also the wbmp and png file) .
    If you can get access to the webtool http://host:port/webtool/login.uix you can click on the system tab and look for
    System > Wireless Server: Administration > Device (look at component configuration).
    From here you can enable/disable standard interface options
    Multi-Channel Server Setup Menu Configuration
    Enable Login
    Enable Logout
    Enable User Info
    Enable Application Customization
    Enable Global Preset
    Enable User Profile
    Enable Self Registration
    Enable User's Home Page
    Enable Help
    Help URL
    You can change the logon page and other pages on <oracle_home>\wireless\j2ee\applications\ptg\ptg-web\modules\login
    and
    <oracle_home>\wireless\j2ee\applications\ptg\ptg-web\modules\iaswfr
    I'm also curious if there is a more easy way to customize things.
    Thomas

  • How to override truncateToFit method for SuperTabNavigator

    Hi All,
               How to override truncateToFit method for SuperTabNavigator.
    we have editableLabel method for changing the tab name.
    it is dispalying the ... elipse when entered characters grater than the tab width. it is ok.
    but if the entered characters less than the tab width it is also appending the ... elipse.
    i dont want that . how to remove those. i dont want completely truncateToFit option.
    how to override .
    Can any help me regarding this?
    Thanks in Advance
    Raghu.

    Give me a sample codeNo. Read the links provided by Yannix, try it out for yourself, and if you still have a question, post the code you tried.
    db

  • How to override component default events

    How to override the scroll panel default click event to custom event.

    Events bubble by default... It sounds like you want to look at the Event class' stopImmediatePropagation method.

  • How to override iMac password?

    how to override iMac password?

    This discussion is for computer built before 2006.  The same solution probably applies to newer computers.
    You can  change the password on an account.  ( Do you know Unix. You are in a Unix single user console. )  The setup commands you need should be listed on the screen.  For Mac OS 10.4.11, the commands are:
    # Type the follow two instructions to access the startup disk in read/write.
    # check out the filesystem.
    # ( in case of partial success repeat this command until errors go away. )
    /sbin/fsck -fy
    # Gain read / write access to your startup drive
    /sbin/mount -uw /
    ->Start up some utility processes that are needed.
    sh /etc/rc
    ->You will probably need to press the return key once the system stops typing.
    ->To find out the users on the system type, use the ls command. The l is a lower case L:
    ls /Users
    ->One of these accounts will be the administrator.
    ->Pick one of the users which I'll call a-user-name and type it in this command:
    passwd a-user-name
    ->and enter the new user password. You need six characters.
    ->You will need to enter your password twice.  Your typing will not show up on the screen just
    -> press enter when you complete the typing.
    ->For cryptic information on these commands try:
    man ls
    man passwd
    The root account isn't enabled by default. I am not sure if changing the password on root will enable it.

  • How to catch exception in JSP????

    how to catch exception in JSP?
    I use JDeveloper 3.1
    I use connection with database .
    When I insert record in database
    when have duplicate of primary key
    how to catch this exception and
    back to previous page?
    I trying with folowing:
    <jsp:useBean id="RowEditor" class="oracle.jbo.html.databeans.EditCurrentRecord" scope="request">
    <% try {
    RowEditor.setUseJS(true);
    RowEditor.initialize(pageContext, "package2_Package2Module.Drzavi1View");
    RowEditor.setSubmitText("Save");
    RowEditor.setTargetUrl("Drzavi1View_SubmitInsertForm.jsp");
    RowEditor.createNewRow();
    RowEditor.setReleaseApplicationResources(true);
    RowEditor.render();
    catch(Exception e) {
    %>
    <script>
    alert("primary key duplication");
    history.back();
    </script>
    <% } %>
    but i't not working
    please help me

    i catch exceptions as you do, i don't have any problem...
    are you throwing the exception from your bean?
    actually i don't catch an Exception, but an SQLException...
    but it works... here is my code...
         try
    myclass.addElement(); // this is an insert into Oracle
    catch( DataBaseFailException e ) /// an exception that i throws inside after i receive an SQLException
              session.setAttribute("gMessage","e.getMessage()); // error code

  • How to run exception using JSP?

    How to run exception using JSP?

    Why would you need the <%%> between the if else blocks? Even if you attempt to write some data within the blocks in java, you will still get an error. For example, this is illegal:
    if(done)
        System.out.println(true);
    System.out.println("Hello World");
    else
        System.out.println(false);
    }The compiler is expecting the 'else' to be directly after the body of the if. If it encounters anything else, it will complain. So you cannot do this in jsp either, regardless if it's a different technology, it's the same compiler.

  • How to handle exceptions in web dyn pro

    Hi Frndz....
                     Can any one kindly xplain how to handle exceptions in web dyn pro..like we hav exceptionhandling in java ....so is there any for NWDS
    THANKS & REGARDS
    Rajesh

    Hi,
    Web Dynpro Java is basically java only.i.e You program in java. Hence exceptions are supported in the same way as in java i.e. via try,catch and finally block.
    Additionally,
    In 04/04s if you create a method in any controller in web dynpro you cann't specify exception that can be thrown in the method. This is now possible in new programming web dynpro model in CE.
    Hence when creating a method you can also specify custom or core java (lib)excetions.
    Regards,
    Ashwani Kr Sharma

  • How to override the default height of tree component...

    Hi,
    Can anyone please tell me how to override the default height of <af:tree> component.
    Actual Problem:
    I have a PanelBox in which I have a ShowDetail component. ShowDetail contains Tree component. When I click on ShowDetail item the Tree component have to be displayed. But, PanelBox is expanding to TREE default height(27.27 ems) instead of expanding to exact height of Tree.
    How to manage this issue?
    Thanks
    -Sukumar

    Did you already try
               <af:treeTable value="#{bindings.DashProjectPhasesDev.treeModel}"
                                  var="node"
                                  selectionListener="#{bindings.DashProjectPhasesDev.treeModel.makeCurrent}"
                                  rowSelection="none" rowBandingInterval="0"
                             inlineStyle="width:810px; height:1100px;"> Check the last line with inlineStyle...
    Julian

  • How to handle exception thrown in standard bo method in the workflow design

    Hi Experts
        how to handle exception thrown from standard bo method in the workflow design. For example, bo BUS2032, METHOD confirm. If the user cancel it, it will throw exception. In the workflow, how to catch this exception and add corresponding steps in the workflow.

    @jrockman li
    Try to implement the logic that what ever you are performing in the BO mehtod in a FM and in the FM you have tab with name EXECPTIONS define the execption in that tab.Now in the BO method you call this FM  and if the exception occurs by using RAISE you can raise the exception in the FM and based on the number of exceptions your sy-subrc value will be set
    so when sys-subrc is not eq 0 then pass a value back t the workflow container., I think this will work.
    a sample Snippet for understanding purpose
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename         = <path>
        filetype         = 'ASC'
      IMPORTING
        filelength       = lv_len
      TABLES
        data_tab         = l_txt_tab
      EXCEPTIONS
        file_write_error = 1          " If this Exception occurs
        invalid_type     = 2
        no_authority     = 3
        unknown_error    = 4
        OTHERS           = 10.
    CASE sy-subrc.
      WHEN 1. " SY-SUBRC value will be 1 then,
          " Pass or set the value back to the workflow conatiner element
    ENDCASE.

Maybe you are looking for