How can I deal with the "throw exception"?

A function has the following definition:
import javax.naming.NamingException;
public BinRelation readBinRelation() throws BadInputDataException,IOException
When I use this function as follows:
BinRelation binRel;
binRel = readBinRelation();
then comes the error:
unreported exception javax.naming.NamingException; must be caught or declared to be thrown.
So how can use this function correctly?
Thanks

So how can use this function correctly?By learning what exceptions are, how they're used, and what you can do to deal with them. There's a tutorial here: http://java.sun.com/docs/books/tutorial/essential/exceptions/index.htmlAnd here's a quick overview:
The base class for all exceptions is Throwable. Java provides Exception and Error that extend Throwable. RuntimeException (and many others) extend Exception.
RuntimeException and its descendants, and Error and its descendants, are called unchecked exceptions. Everything else is a checked exception.
If your method, or any method it calls, can throw a checked exception, then your method must either catch that exception, or declare that your method throws that exception. This way, when I call your method, I know at compile time what can possibly go wrong and I can decide whether to handle it or just bubble it up to my caller. Catching a given exception also catches all that exception's descendants. Declaring that you throw a given exception means that you might throw that exception or any of its descendants.
Unchecked exceptions (RuntimeException, Error, and their descendants) are not subject to those restrictions. Any method can throw any unchecked exception at any time without declaring it. This is because unchecked exceptions are either the sign of a coding error (RuntimeException), which is totally preventable and should be fixed rather than handled by the code that encounters it, or a problem in the VM, which in general can not be predicted or handled.

Similar Messages

  • How can i deal with the BAD_INV_ORDER error?

    help me ,My corba client throw a BAD_INV_ORDER Exception ,why?

    See this link http://java.sun.com/j2se/1.4.1/docs/api/org/omg/CORBA/BAD_INV_ORDER.html

  • How can I deal with long sql by the oo4o?

    I am using VB and oo4o to develop a sql executor which is a extention of an old system.
    For some reason, I have to use oo4o v8.1.7 to deal with Oracle Database 8i to 11g.
    But when I send a very long sql(11KB) to it I got a error in the VB enviroment.
    The Err.Description is "automention error. Started object is disconnected by the client.".
    The Err.Number is "-2147417848 ".
    The sql that I send it to the program is a simple select sql that like select a, b, c, substrb(d, 1, 2), substrb(e, 2, 3) .... from A_TBL where A=aa;
    This sql is normally executed by the sqlplus but I got an error by the oo4o.
    When I insert a '' between the 30Xth items, it got exectuted normally.
    ex. select a, b, c, substrb(d, 1, 2), substrb(e, 1, 2) ..... substrb(303th, 3, 4), '', substrb(304th, 1, 2) ... from A_TBL where A = aa;
    How can I deal with this problem? Thanks.

    So how can use this function correctly?By learning what exceptions are, how they're used, and what you can do to deal with them. There's a tutorial here: http://java.sun.com/docs/books/tutorial/essential/exceptions/index.htmlAnd here's a quick overview:
    The base class for all exceptions is Throwable. Java provides Exception and Error that extend Throwable. RuntimeException (and many others) extend Exception.
    RuntimeException and its descendants, and Error and its descendants, are called unchecked exceptions. Everything else is a checked exception.
    If your method, or any method it calls, can throw a checked exception, then your method must either catch that exception, or declare that your method throws that exception. This way, when I call your method, I know at compile time what can possibly go wrong and I can decide whether to handle it or just bubble it up to my caller. Catching a given exception also catches all that exception's descendants. Declaring that you throw a given exception means that you might throw that exception or any of its descendants.
    Unchecked exceptions (RuntimeException, Error, and their descendants) are not subject to those restrictions. Any method can throw any unchecked exception at any time without declaring it. This is because unchecked exceptions are either the sign of a coding error (RuntimeException), which is totally preventable and should be fixed rather than handled by the code that encounters it, or a problem in the VM, which in general can not be predicted or handled.

  • It says that "there was a problem connecting to the server". What's wrong with this, and how can I deal with this problem?

    I just got my new iPad Mini2, and when I choose "sign in with your apple ID", it says that "there was a problem connecting to the server". What's wrong with this, and how can I deal with this problem?

    1. Turn router off for 30 seconds and on again
    2. Settings>General>Reset>Reset Network Settings

  • HT5621 I have moved permanently from the US to live in the UK. when I try to download a UK app I am often told that I cannot use a UK Apple sstore, only a US store. I need to access various UK stores how can I deal with this?

    I have moved permanently from the US to live in the UK. when I try to download a UK app I am often told that I cannot use a UK Apple sstore, only a US store. I need to access various UK stores how can I deal with this?

    Try here
    http://support.apple.com/kb/HT1311
    when you have UK Cards etc best to change as well

  • TS1436 I received this message twice on 2 new & separate attempts to burn a playlist to a NEW cd:  "The attempt to burn a disc failed.  The burn failed because of a medium write error."  What is a "medium write error" and how can I deal with this?

    I received this message twice on 2 new & separate attempts to burn a playlist to a NEW cd:  "The attempt to burn a disc failed.  The burn failed because of a medium write error."  What is a "medium write error" and how can I deal with this?

    Hello Pat,
    The following article provides troublehsooting steps and information that can help get iTunes burning discs again.
    Can't burn a CD in iTunes for Windows
    http://support.apple.com/kb/TS1436
    Cheers,
    Allen

  • Hi apple am new user to apple i just bought i phone 4s  and  i set up passowrd and forgot it how  and the iphone is not responding now how can i deal with this broblem please helpe

    hi apple am new user to apple i just bought i phone 4s  and  i set up passowrd and forgot it how  and the iphone is not responding now how can i deal with this broblem please helpe

    iPhone User Guide (For iOS 5.1 Software)

  • Adobe always quits unexpectedly in Mac when I read a bit fast. How can i deal with it, plz?

    Adobe always quits unexpectedly in Mac when I read a bit fast.
    It is the latest update.
    How can i deal with it, plz?

    You posted in the forum for iPad and iPhone (different app). I've moved your question to the Reader forum for desktop/laptop computers.

  • How can I deal with an apostrophy

    My simple questions is how can I deal with an apostrophy when I trying to save to the table, here is an example in how I am saving.
    'Sandr'as Casa' this gives me an error message. I have to do it like this
    Strings.replace("Sandr'as Casa"," ' "," ' ' "), a package function
    SQLDesFollow = "UPDATE [CRVMReq] " +
    "SET [SkillSet]='" + Strings.replace("Sandr'as Casa"," ' "," ' ' ")+ "'" WHERE [ReqId]='" + ReqValuesReqId[4] + "";
    dbs.execute(SQLDesFollow);
    SQLDesFollow = "UPDATE [CRVMReq] " +
    "SET [SkillSet]='Sandr'as Casa' WHERE [ReqId]='" + ReqValuesReqId[4] + "";
    dbs.execute(SQLDesFollow);
    any help will be appreciated.

    Here is the magic word: PreparedStatement.
    Start here:
    http://java.sun.com/docs/books/tutorial/jdbc/basics/pr
    epared.htmlSeconded, thirded and fourthed.
    And if later readers of this thread feel that they would like to provide another answer then they should think again because they would be wrong.
    There is only one correct answer to this question. PreparedStatement.

  • How can I print with the black and white cartridge only?

    I am trying to print using the black and white cartridge only because magenta is out of ink but I'm getting the following error message in HP Photosmart C7200 series print dialog:
    The printer is out of ink.
    The following ink cartridges are empty: Magenta. Replace these ink cartridges to resume printing.
    How can I print with the black and white cartridge only?
    Mac OSX 10.7.3
    HP Photosmart C7280 (7200 series)
    This question was solved.
    View Solution.

    I am absolutely disgusted by this; clearly a scam from HP to make more money by selling extra ink cartridges!!  I will make sure to never buy any products from the shoddy rip off merchants at HP ever again!!
    You should be ashamed!!

  • How do I deal with the"new itunes library" fiasco

    how do I deal with the "new itunes library" fiasco...?

    Recovering your iTunes library from your iPod or iOS device: Apple Support Communities

  • How can I connect with the AspNetUsers table in MVC 5?

    I have a model, in which I have used several foreign keys from other tables. The point is that I also need to get the Id of the user, from the AspNetUsers table, though, I don't know how. I have done something like this, but it doesn't seem to be working:
    public class Message
        public int MessageID { get; set; }
        [Required(ErrorMessage="Please type a message to submit")]
        [DataType(DataType.MultilineText)]
        [Display(Name="Message")]
        public string MessageText { get; set; }
        public DateTime WrittenOn { get; set; }
        [Required(ErrorMessage="Please select a ticket")]
        [ForeignKey("Ticket")]
        [Display(Name="Ticket")]
        public int TicketID { get; set; }
        public virtual Ticket Ticket { get; set; }
        [Required(ErrorMessage = "Please select a business")]
        [ForeignKey("Business")]
        [Display(Name = "Business")]
        public int BusinessID { get; set; }
        public virtual Business Business { get; set; }
        [Required(ErrorMessage = "Please select a user")]
        [ForeignKey("aspnetusers")]
        [Display(Name = "User")]
        public int Id { get; set; }
        public virtual ApplicationUser ApplicationUser { get; set; }
    When I try to create a controller using the Entity Framework with my model, I get an error message saying:
        The ForeignKeyAttribute on property 'Id' on type ... is not valid. The navigation property 'aspnetusers' was not found on the dependent type ... The Name value should be a valid navigation property name.
    If someone could help me solve the problem, I would be glad.

    Hi Toni,
    I see that this particular query is been answered in the following thread.
    http://stackoverflow.com/questions/25372436/how-can-i-connect-with-the-aspnetusers-table-in-mvc-5
    You can also refer the following links, hope this helps.
    http://stackoverflow.com/questions/20071282/aspnet-identity-and-mvc5
    http://blogs.msdn.com/b/webdev/archive/2013/10/16/customizing-profile-information-in-asp-net-identity-in-vs-2013-templates.aspx
    Regards,
    Bharath

  • HT201274 Can a Sprint Iphone 5 work with T-mobile network? How can one unlock with the MSL code? Sprint is not abiding by the Unlocking Consumer Choice and Wireless Competition Act.  FCC will only enforce if we file more complains.

    Can a Sprint Iphone 5 work with T-mobile network? How can one unlock with the MSL code? Sprint is not abiding by the Unlocking Consumer Choice and Wireless Competition Act.  FCC will only enforce if we file more complains.

    T-Mobile is a GSM network whereas Sprint is a CDMA network. They are incompatible. Sprint is not obliged to unlock a phone that is still under contract. Their phones may not be capable of being unlocked.

  • How can i deal with Exception of URI

    I am learning Expression Language, in one of the examples, there is a sentence like this: <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jst1/fmt" %>.
    the browser will throw an exception:
    org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application.
    How can i do with it? Thanks!

    put the standard.jar on the apllication classpath WEB-INF/lib

  • How Oracle to deal with the data lose?-----QNo.104

    In incomplete recovery,some data will be lost. How Oracle to deal with it?
    For example, at 9:00am, you find that it is a mistake to drop a user(you dropped it at 8:30am). But other users' transactions are in progress. A lot of data is input between 8:30 and 9:00. If decide to make a incomplete recovery, does this means all the data input between 8:30 and 9:00 will be lost?
    Message was edited by:
    frank.qian
    Message was edited by:
    frank.qian

    For example, at 9:00am, you find that it is a mistake to drop a user(you dropped it at 8:30am. But the transactions are in progress. To make you clear, you can't drop the user while session connected to this schema.
    I dont think that you would loose any data.
    The other workaround for this issue would be,
    I would clone this on other server just before the user dropped, take the export and then import the user in the production.
    Is this satisfy your question?
    Jaffar

Maybe you are looking for

  • My udating Firefox failed and not I cannot access it

    I tried updating Firefox on Tuesday and somehow it overloaded my Mac and now all I have is the Firefox symbol with a circle/slash through it and it does not function. I tried downloading SeaMonkey and have the same result. I know the two are related

  • BW Data Load failure

    Hi,    I created a BW Data Source in R/3 and checked in RSA3 (R/3) it is extracting the required record... But when i started data load in BW using that extractor i am geting error message <b>Request IDoc : Application document not posted</b> How can

  • Move iPhoto images back to iPhone

    I moved the images first from iPhone to iPhoto. Now that they are edited I want to move them back from iPhoto to iPhone. Is this possible?

  • Mac OS 10.5.8 PPC doesn't keep standby modus

    Hi, anybody has an idea why my good old PPC G5 doesn't want to keep its stand by modus? Thanks for any help, Simon

  • Task Sequence Fails after Software Updates Install Step - Lenovo X240

    Hi All. I'm having a strange issue trying to run an OSD on Lenovo X240 machines.  After the Software Update step, it reboots as expected, then exits the task sequence and sends you to the windows logon screen. Review the SMSTS.log, it appears the rea