Try/Catch Unknown Host Exception

I need to validate for an error of Unknown Host Exception, in case someone tries connected to a server that doesn't exist, or types the wrong host name, so i can display a message. how do I do that, with a try catch block.
I thought i would do:
try{
      my code here such as...
      DatagramSocket socket = new DatagramSocket();
      // send request
      InetAddress address = InetAddress.getByName(args[0]);
      DatagramPacket packet = new DatagramPacket(buf, buf.length, address, 4445);
      socket.send(packet);
    ...and so on, more code...
       socket.close();
} catch (IOException e) {
       e.printStackTrace();
       System.out.println("Unknown host " + args[0]);
}

thanks, i also had to take out the e.printStackTrace(); and replace that with
my error message and System.exit(0); and I got what i needed!

Similar Messages

  • Tunneling and problem with unknown host exception

    hello! i've got a problem with https. i use jdk 1.5.0, jboss-4.0.4.ga-patch1, soap.
    and i'm going crasy.. i've testet my client code at our network and it works fine. but if i want to get jobs from the server of our customer, my client throw an "unknown host exception: firm".
    i wonder why it hasn't the full host. the url may look like this: https://firm.sub.com:443/ and while the client connects to the server, i depugged it and the host is correct: firm.sub.
    but after the connection, when the client want to get something from the server (when it wants to communicate with the server over soap) it crashs.
    my client code looks like this:
    private ClientInterfaceEndpoint getClientInterface() throws ServiceException {
    QName serviceQName = new QName(DOCSERVER_NAMESPACE, CLIENT_INTERFACE_SERVICENAME);
    URL wsdlUrl = getClientInterfaceWsdlUrl();
    log.info("*******WSDLURL host: " + wsdlUrl.getHost()); // out: firm.sub
    log.info("*******WSDLURL port: " + wsdlUrl.getPort()); // out: 443
    URL mapping = getClass().getClassLoader().getResource("META-INF/DocumentServer_Mapping.xml");
    log.info("*******MappingURL path: " + mapping.getPath());
    if (wsdlUrl.toString().toLowerCase().contains("https")) {
    if (null == getConfig().getTruststore() || getConfig().getTruststore().equalsIgnoreCase("")) {
    throw new RuntimeException("No or incorrect TruststorePath in the docclient-config");
    File tmp = new File(getConfig().getTruststore());
    if (!tmp.isFile() || !tmp.canRead()) {
    throw new RuntimeException("The truststore at the 'TruststorePath' isn't a file or can't be read.");
    System.setProperty(SYS_PROPERTY_KEY_TRUST, getConfig().getTruststore());
    System.setProperty(SYS_PROPERTY_KEY_TRUST_PW, config.getTruststorePass());
    ServiceFactoryImpl factory = null;
    factory = (ServiceFactoryImpl) ServiceFactory.newInstance();
    Service clientInterfaceService = null;
    try {// create the service for the ClientInterface
    clientInterfaceService = factory.createService(wsdlUrl, serviceQName, mapping, new URL(config.getServerURL())); //, new URL(config.getServerURL())
    log.info("*******ClientInterFaceService WSDL URL Host: " + clientInterfaceService.getWSDLDocumentLocation().getHost()); // out:firm.sub
    log.info("*******ClientInterFaceService WSDL URL Port: " + clientInterfaceService.getWSDLDocumentLocation().getPort()); // out: 443
    } catch (ServiceException e) {
    log.error(e.getMessage());
    throw new RuntimeException(e.getMessage());
    } catch (MalformedURLException e) {
    log.error(e.getMessage());
    throw new RuntimeException(e.getMessage());
    } catch (Exception e) {
    log.error(e.getMessage());
    throw new RuntimeException(e.getMessage());
    }// getting the ClientInterfaceEndpoint
    ClientInterfaceEndpoint clientInterface = (ClientInterfaceEndpoint) clientInterfaceService.getPort(ClientInterfaceEndpoint.class);
    return clientInterface;
    protected URL getClientInterfaceWsdlUrl() {
    URL url = null;
    String urlString = getConfig().getServerURL() + CLIENT_INTERFACE_URI + "?wsdl";
    Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
    Properties properties = System.getProperties();
    String handlers = System.getProperty(SYS_PROPERTY_KEY_PKGS);
    if (handlers == null) {
    properties.put(SYS_PROPERTY_KEY_PKGS, SYS_PROPERTY_VALUE_PKGS);
    else {
    properties.put(SYS_PROPERTY_KEY_PKGS, SYS_PROPERTY_VALUE_PKGS.concat("|").concat(handlers));
    try {
    url = new URL(urlString);
    log.info("*******URL host: " + url.getHost());
    log.info("*******URL port: " + url.getPort());
    log.info("*******URL path: " + url.getPath());
    } catch (MalformedURLException e) {
    log.fatal("DocumentProvider SOAP configured incorrectly. DocServer URL malformed: " + urlString);
    throw new RuntimeException("DocumentProvider SOAP configured incorrectly. DocServer URL malformed: " + urlString, e);
    System.setProperties(properties);
    return url;
    }if it's usefull: the customer use a apache server (not tomcat) where a the server is and the client at another system the jboss.
    The customer told me: if i want to connect the client via http i have to tunnel.. maybe i have to tunnel using https too?
    have i to generate the endpoint classes a second time, extra for https?
    or doesn't soap like host like "firm.sub"?
    can anyone help me please?!
    sorry, my english isn't very well...

    sorry, it's not the same error. The output is: Unable to connect to any host due to exception: java.net.socket.exception: java.net.socket.exception: Unregcognized windows socket error: 10106: create.

  • InetAddress posting Unknown Host Exception

    Hello,
    I am relatively new to java and I am running into an Unknown Host Exception when attempting to return the IP's for valid host names. The strange part is that the first host name returns an address however every entry after the first returns the Unkown Host Exception. Here is the snippet of code that the problem is occuring in.
    Inet address as declared earlier in the code:
         private InetAddress Address = null;Code reporting errors:
              StringBuffer sb0 = new StringBuffer();
              int chr;
              // Read until the end of the stream     
              while ((chr = inputStream0.read()) != -1)
                      sb0.append((char) chr);
              String display = sb0.toString();
              String temp = display.replace("Giant ", "g0");
              String[] words = temp.split("\\|");
              StringBuffer db = new StringBuffer();
              for (int i=0; i < words.length; i++)
                      String many = (words[i] +"wu1");
                      try
                              Address = InetAddress.getByName(many);
                   db.append(words[i] + "wu1|" + Address);
                      catch(NullPointerException e)
                              db.append(words[i] + "wu1 - Null Pointer - ");
                      catch(UnknownHostException e)
                              db.append(words[i] + "wu1 - Unknown Host - ");
              String yay = db.toString();
              log.append(yay);
                                    catch (FileNotFoundException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
                                    catch (IOException e)
              // TODO Auto-generated catch block
              e.printStackTrace();
              }I have attempted setting Address back to null after the address was appended but it didn't make any difference.
    Edited by: mudbuggle on Aug 4, 2008 7:19 PM

    I made the adjustments however I am still experiencing the same problem.
    www.yahoo.com returns an ip address but the rest return Unknown Host Exceptions.
    www.yahoo.comjava.net.UnknownHostException:
    forums.sun.com
         at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)
         at java.net.InetAddress$1.lookupAllHostAddr(Unknown Source)
         at java.net.InetAddress.getAddressFromNameService(Unknown Source)
         at java.net.InetAddress.getAllByName0(Unknown Source)
         at java.net.InetAddress.getAllByName(Unknown Source)
    forums.sun.com     at java.net.InetAddress.getAllByName(Unknown Source)
         at java.net.InetAddress.getByName(Unknown Source)
         at IP$1.actionPerformed(IP.java:83)
         at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
         at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
         at javax.swing.AbstractButton.doClick(Unknown Source)
         at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
         at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
         at java.awt.Component.processMouseEvent(Unknown Source)
         at javax.swing.JComponent.processMouseEvent(Unknown Source)
         at java.awt.Component.processEvent(Unknown Source)
         at java.awt.Container.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Window.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)
    java.net.UnknownHostException:
    www.google.com
         at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)
         at java.net.InetAddress$1.lookupAllHostAddr(Unknown Source)
         at java.net.InetAddress.getAddressFromNameService(Unknown Source)
         at java.net.InetAddress.getAllByName0(Unknown Source)
         at java.net.InetAddress.getAllByName(Unknown Source)
         at java.net.InetAddress.getAllByName(Unknown Source)
         at java.net.InetAddress.getByName(Unknown Source)
         at IP$1.actionPerformed(IP.java:83)
         at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
         at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
         at javax.swing.AbstractButton.doClick(Unknown Source)
         at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
         at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
         at java.awt.Component.processMouseEvent(Unknown Source)
         at javax.swing.JComponent.processMouseEvent(Unknown Source)
         at java.awt.Component.processEvent(Unknown Source)
         at java.awt.Container.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Window.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)

  • Unknown host exception when weblogic is a https client to another server

    Hi,
    I have weblogic 6.1 sp2. My program connects as a client using https protocol.
    For this the classes provided by wls are used .
    The key , cert and ca files are of weblogic available in wlserver6.1\config\mydomain
    demokey.pem, democert.pem and ca.pem, installed during weblogic installation
    When this code is exceuted it gives a Unknown host exception at the point when
    trying to connect to the url.
    Are there any settings required in weblogic ?
    Regards
    Lata

    Hi,
    I have weblogic 6.1 sp2. My program connects as a client using https protocol.
    For this the classes provided by wls are used .
    The key , cert and ca files are of weblogic available in wlserver6.1\config\mydomain
    demokey.pem, democert.pem and ca.pem, installed during weblogic installation
    When this code is exceuted it gives a Unknown host exception at the point when
    trying to connect to the url.
    Are there any settings required in weblogic ?
    Regards
    Lata

  • Unknown Host Exception

    Hi,
    I keep getting an UnknownHostException with my JavaMail code. I think the trouble is that my SMTP host is a computer name. Does anyone have any idea is JavaMail doesn't allow computer names as SMTP hosts. I know the host is there, as I have sent email through it using ASP pages before.
    Here's the code just incase it helps. But I know it's correct as I got it off the internet.
    package Gomez;
    import java.io.*;
    import java.util.*;
    import javax.mail.*;
    import javax.mail.event.*;
    import javax.mail.internet.*;
    public final class MailerBean extends Object implements Serializable {
         /* Bean Properties */
         private String to = null;
         private String from = null;
         private String subject = null;
         private String message = null;
         public static Properties props = null;
         public static Session session = null;
         static {
              /*     Setting Properties for STMP host */
              props = System.getProperties();
              props.put("mail.smtp.host", "\\\\svaaoffnot17\\");
              session = Session.getDefaultInstance(props, null);
         /* Setter Methods */
         public void setTo(String to) {
              this.to = to;
         public void setFrom(String from) {
              this.from = from;
         public void setSubject(String subject) {
              this.subject = subject;
         public void setMessage(String message) {
              this.message = message;
         /* Sends Email */
         public void sendMail() throws Exception {
              if(!this.everythingIsSet())
                   throw new Exception("Could not send email.");
              try {
                   MimeMessage message = new MimeMessage(session);
                   message.setRecipient(Message.RecipientType.TO,
                        new InternetAddress(this.to));
                   message.setFrom(new InternetAddress(this.from));
                   message.setSubject(this.subject);
                   message.setText(this.message);
                   Transport.send(message);
              } catch (MessagingException e) {
                   throw new Exception(e.getMessage());
         /* Checks whether all properties have been set or not */
         private boolean everythingIsSet() {
              if((this.to == null) || (this.from == null) ||
                 (this.subject == null) || (this.message == null))
                   return false;
              if((this.to.indexOf("@") == -1) ||
                   (this.to.indexOf(".") == -1))
                   return false;
              if((this.from.indexOf("@") == -1) ||
                   (this.from.indexOf(".") == -1))
                   return false;
              return true;
    }

    You need to find the name of the server, and that isn't it. So use ASP to send an e-mail to some address where you can look at the headers. One of these headers will say something like "sent from mail.svaaoffnot17", and that's the name you want to use. Or you could ask the server's administrator...

  • Unknown Host Exception while starting weblogic 6.0

    Hi,
    While starting weblogic 6.0 on win 95, i get following error.
    [java.net.UnknownHostException: default]
    weblogic.utils.NestedError: Local host not known?! - with nested exception:
    I have tried to change ports from 7001 and 7002, error is still there. I work on
    a desktop, dont have any proxy settings.
    What else can be done?

    Hi.
    Again, this is not a supported platform. I also believe this is some kind of network
    setup issue on your win95 machine. Try comparing the tcp/ip setup differences between
    your win98 machine and your win95 machine. If you are using dhcp you should try to
    change your settings to support a static ip.
    Good luck.
    Michael
    Tarang wrote:
    Hi,
    I am attaching complete error message, may be you can throw more light. I tried the
    same installation on win 98, it is working fine. On my machine, variable is defined
    as localhost only.
    [java.net.UnknownHostException: default]
    weblogic.utils.NestedError: Local host not known?! - with nested exception:
    [java.net.UnknownHostException: default]
    at weblogic.rjvm.JVMID.setLocalID(JVMID.java:86)
    at weblogic.rjvm.JVMID.localID(JVMID.java:67)
    at weblogic.rjvm.LocalRJVM.getID(LocalRJVM.java:130)
    at weblogic.i18ntools.L10nLookup$Logger.<init>(L10nLookup.java:282)
    at weblogic.i18ntools.L10nLookup.<init>(L10nLookup.java:114)
    at weblogic.i18ntools.L10nLookup.init(L10nLookup.java:70)
    at weblogic.i18ntools.L10nLookup.getL10n(L10nLookup.java:58)
    at weblogic.logging.LogManager.initialize(LogManager.java:66)
    at weblogic.t3.srvr.T3Srvr.initialize(T3Srvr.java:322)
    at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:169)
    at weblogic.Server.main(Server.java:35)
    Tarang
    Michael Young <[email protected]> wrote:
    Hi.
    The port is not the problem, it's something with your network setup - localhost
    is
    not properly defined. I'm not sure about the error you posted below, but
    FWIW it
    should be defined as localhost, not 'local host' (note the space).
    In the bigger picture, however, you should try running WLS on a supported
    platform.
    See the following link for this:
    http://edocs.bea.com/wls/platforms/index.html
    Regards,
    Michael
    Tarang wrote:
    Hi,
    While starting weblogic 6.0 on win 95, i get following error.
    [java.net.UnknownHostException: default]
    weblogic.utils.NestedError: Local host not known?! - with nested exception:
    I have tried to change ports from 7001 and 7002, error is still there.I work on
    a desktop, dont have any proxy settings.
    What else can be done?--
    Michael Young
    Developer Relations Engineer
    BEA Support
    Michael Young
    Developer Relations Engineer
    BEA Support

  • Unknown host exception in Workshop 4 Weblogic including a XSD in a WSDL

    Hi All,
    Im facing a bug in W4W as it throws unknownhostexception when im including a LOCAL schema in a WSDL.
    Im using Linux (Ubuntu). In windows, this bugs does not happen.
    Is it a known bug? Is there a patch for it?
    Thanks in advance!,
    Daniel
    Edited by danielamadei at 10/11/2007 6:15 AM

    Hi,
    I have exactly the same kind of issue.
    I'm working with:
    BEA version: 9.2.2
    build id: 952826
    I've imported a WSDL file from my file system into a package, right click on the WSDL file and then choosed "Web Service/Generate web service..."
    Workshop starts working and stops with the following error "UnknowHostException: opt" (FYI: I've installed WorkShop in /opt/bea)
    Doing exactly the same thing on Windows works.
    Jean-Marc
    Stack trace generated trying to generate a WebControl from the WSDL file (I guess this is the same kind of exception):
    com.bea.wlw.controls.service.ui.except.TypesAnalysisFailedException: weblogic.wsee.wsdl.WsdlException: Failed to read wsdl file from url due to -- java.net.UnknownHostException: opt
    at com.bea.wlw.controls.service.ui.util.ProcessServiceInfo.run(ProcessServiceInfo.java:100)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:113)
    Caused by: weblogic.wsee.wsdl.WsdlException: Failed to read wsdl file from url due to -- java.net.UnknownHostException: opt
    at weblogic.wsee.wsdl.WsdlReader.getDocument(WsdlReader.java:313)
    at weblogic.wsee.wsdl.WsdlDefinitions.parse(WsdlDefinitions.java:362)
    at weblogic.wsee.wsdl.WsdlDefinitions.parse(WsdlDefinitions.java:352)
    at weblogic.wsee.wsdl.WsdlImport.parse(WsdlImport.java:93)
    at weblogic.wsee.wsdl.WsdlDefinitions.parseChild(WsdlDefinitions.java:462)
    at weblogic.wsee.wsdl.WsdlExtensible.parse(WsdlExtensible.java:98)
    at weblogic.wsee.wsdl.WsdlDefinitions.parse(WsdlDefinitions.java:405)
    at weblogic.wsee.wsdl.WsdlDefinitions.parse(WsdlDefinitions.java:362)
    at weblogic.wsee.wsdl.WsdlFactory.parse(WsdlFactory.java:50)
    at weblogic.wsee.wsdl.WsdlFactory.parse(WsdlFactory.java:73)
    at weblogic.wsee.wsdl.WsdlFactory.parse(WsdlFactory.java:38)
    at com.bea.wlw.controls.service.ui.util.WsdlAnalyzer.load(WsdlAnalyzer.java:27)
    at com.bea.wlw.controls.service.ui.util.WsdlAnalyzer.analyzeWsdl(WsdlAnalyzer.java:21)
    at com.bea.wlw.controls.service.ui.util.ProcessServiceInfo.run(ProcessServiceInfo.java:93)
    ... 1 more
    Caused by: java.net.UnknownHostException: opt
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
    at java.net.Socket.connect(Socket.java:519)
    at java.net.Socket.connect(Socket.java:469)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
    at sun.net.NetworkClient.openServer(NetworkClient.java:118)
    at sun.net.ftp.FtpClient.openServer(FtpClient.java:488)
    at sun.net.ftp.FtpClient.openServer(FtpClient.java:475)
    at sun.net.www.protocol.ftp.FtpURLConnection.connect(FtpURLConnection.java:270)
    at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(FtpURLConnection.java:352)
    at weblogic.wsee.util.dom.DOMParser.getWebLogicDocumentImpl(DOMParser.java:149)
    at weblogic.wsee.util.dom.DOMParser.getDocument(DOMParser.java:59)
    at weblogic.wsee.wsdl.WsdlReader.getDocument(WsdlReader.java:311)
    ... 14 more
    Edited by desmo999r at 11/12/2007 10:49 AM
    Edited by desmo999r at 11/12/2007 10:56 AM

  • Connectivity issue -unknown host

    Hi,
    We have an File to File interface from SAP ECC to Click .We are getting unknown host exception while trying to connect from PI .We checked with Click team they confirmed there server is up and running .
    Could you please advice what might be the issue?

    Hi,
    Check with Click team whether they have file server installed in there server machine or not?
    By the way did u tried connecting from front end tools like filezilla or by connecting from os level ?
    Regards
    Venkat

  • Io exception: Unknown host specified

    hi all
    i installed oracle 10g successfuly but when i open enterprize manager and try to connect system as sysdba then follwoing error occure
    Io exception: Unknown host specified
    can any one help me
    thanks in advance

    i am giving the os username and pasword but the error is
    RemoteOperationException: ERROR: Wrong password for user

  • RAISERROR with Try/Catch does not exit after exception in catch block

    I am trying to propogate an error from within my proc out to the caller.
    In the attached example I have 2 sets of try catch blocks.
    I raiserror in the first
    catch the error and then raiserror again. (I expect to exit)
    I do not expect :
    to get to print 'post test'
    to get to second try block.
    but this does not exit, instead the code flows as per 2 runs.
    I do not understand the reason for the flows, as it seems counterintuitive to be raising an error but then still print following exceptions. I cannot seem to find any references that explains this behaviour.
     running tests together results
    print '-------------------------------------------------------'
    print 'test 15'
    exec test_raiseerror 15
    print '-------------------------------------------------------'
    print 'test 16'
    exec test_raiseerror 16
    print '-------------------------------------------------------'
    print 'test 17'
    exec test_raiseerror 17
    print '-------------------------------------------------------'
    print 'test 18'
    exec test_raiseerror 18
    print '-------------------------------------------------------'
    'RESULTS'
    test 15
    error number provided: 15
    Msg 50000, Level 15, State 1, Procedure test_raiseerror, Line 21
    name hello 15
    post test
    15
    Msg 50000, Level 15, State 1, Procedure test_raiseerror, Line 37
    name hello 2 15
    post test2
    test 16
    error number provided: 16
    Msg 50000, Level 16, State 1, Procedure test_raiseerror, Line 21
    name hello 16
    post test
    16
    Msg 50000, Level 16, State 1, Procedure test_raiseerror, Line 37
    name hello 2 16
    post test2
    test 17
    error number provided: 17
    post test
    17
    post test2
    test 18
    error number provided: 18
    post test
    18
    post test2
    Msg 50000, Level 17, State 1, Procedure test_raiseerror, Line 21
    name hello 17
    Msg 50000, Level 17, State 1, Procedure test_raiseerror, Line 37
    name hello 2 17
    Msg 50000, Level 18, State 1, Procedure test_raiseerror, Line 21
    name hello 18
    Msg 50000, Level 18, State 1, Procedure test_raiseerror, Line 37
    name hello 2 18
    run tests seperately
    exec test_raiseerror 15
    error number provided: 15
    RESULTS 15
    Msg 50000, Level 15, State 1, Procedure test_raiseerror, Line 21
    name hello 15
    post test
    15
    Msg 50000, Level 15, State 1, Procedure test_raiseerror, Line 37
    name hello 2 15
    post test2
    exec test_raiseerror 16
    RESULTS 16
    error number provided: 16
    Msg 50000, Level 16, State 1, Procedure test_raiseerror, Line 21
    name hello 16
    post test
    16
    Msg 50000, Level 16, State 1, Procedure test_raiseerror, Line 37
    name hello 2 16
    post test2
    exec test_raiseerror 17
    RESULTS 17
    error number provided: 17
    post test
    17
    post test2
    Msg 50000, Level 17, State 1, Procedure test_raiseerror, Line 21
    name hello 17
    Msg 50000, Level 17, State 1, Procedure test_raiseerror, Line 37
    name hello 2 17
    exec test_raiseerror 18
    RESULTS 18
    error number provided: 18
    post test
    18
    post test2
    Msg 50000, Level 18, State 1, Procedure test_raiseerror, Line 21
    name hello 18
    Msg 50000, Level 18, State 1, Procedure test_raiseerror, Line 37
    name hello 2 18
     CODEBLOCK:
    if object_id('test_raiseerror','P') is not null
    drop proc test_raiseerror
    go
    create proc test_raiseerror(@id as int) as
    begin
    begin try
    declare @name varchar(20)
    select @name = 'hello'
    raiserror('name %s %d',@id,1,@name,@id)
    print 'next'
    end try
    begin catch
    declare @errormessage nvarchar(4000)
    declare @errornum int
    select @errormessage = error_message()
    , @errornum = error_severity()
    print 'error number provided: ' + convert(varchar(2),@errornum)
    raiserror(@errormessage, @errornum,1)
    print 'post test'
    end catch
    begin try
    select @name = 'hello 2'
    raiserror('name %s %d', @id,1,@name, @id)
    end try
    begin catch
    select @errormessage = error_message()
    , @errornum = error_severity()
    print @errornum
    raiserror(@errormessage, @errornum,1)
    print 'post test2'
    end catch
    end
    go
    sqlserver 2008 & 2008 R2

    There is a Connect that describes a similiar complaint.  But basically a raiserror inside a catch block does not terminate the procedure, it will continue with any additional code in the CATCH and FINALLY unless it hits a return statement.
    http://connect.microsoft.com/SQLServer/feedback/details/275308/have-raiserror-work-with-xact-abort

  • Exception handling with try/catch in acrobat

    Hi
    I have a problem using a try/catch block in my acrobat document-script. Try to enter the following into the debugger-console:
    try{nonexistentFunction();}catch(e){console.println('\nacrobat can't catch')}
    and run it. The output will be:
    nonexistentFunction is not defined
    1:Console:Exec
    acrobat can't catch
    true
    The whole point of a rty/catch block is for the application  NOT to throw an exception, but instead execute the catch-part of the  statement. However, acrobat does both: It throws an exception AND  executes the catch-block.
    Is there another way to suppress the exception, or to make the try/catch-block work as it's supposed to?

    > Also Adobe provides for free the JS or compiled file for Acrobat Reader to support the JS console.
    Where is that file located ? How to install it or where to place it ?
    What is the method referred by try67 on his site where he sells a product ?
    Is that the same as the compiled file you refer to ? or did he sell his solution to adobe ?
    It is helpful if people can get an idea of the nature of choices available and make informed decisions, than a cloak and dagger approach.
    For some jobs that we have, I have been very frustrated by a consultant who wont even give basic info for transparent billing despite all assurances for privacy, as a result we are forced to do the job ourselves.
    Dying Vet

  • My firefox is not running- when i try to open it their appears.. "The exception unknown software exception (0xc0000417) occurred in the application at location

    <blockquote>Locking duplicate thread.<br>
    Please continue here: [[/questions/942433]]</blockquote>
    my firefox is not running… when i try to open it their appears.. “The exception unknown software exception (0xc0000417) occurred in the application at location 0x78b2ae6e” ..what can i do..????
    REPLY

    If you have submitted crash reports then please post the IDs of one or more crash reports that have this format:
    *bp-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
    See:
    *http://kb.mozillazine.org/Mozilla_Crash_Reporter
    *https://support.mozilla.org/kb/Mozilla+Crash+Reporter
    If you can't open Firefox then see:
    *http://kb.mozillazine.org/Mozilla_Crash_Reporter#Location_of_crash_reports
    *http://kb.mozillazine.org/Mozilla_Crash_Reporter#Viewing_crash_reports
    See also:
    *http://kb.mozillazine.org/Firefox_crashes
    *https://support.mozilla.org/kb/Firefox+crashes
    Try a clean reinstall and delete the Firefox program folder before reinstalling a fresh copy of Firefox.
    *C:\Program Files\Mozilla Firefox\
    *http://kb.mozillazine.org/Installation_directory
    Download a fresh Firefox copy and save the file to the desktop.
    *Firefox 17.0.x: http://www.mozilla.org/en-US/firefox/all.html
    Uninstall your current Firefox version, if possible, to cleanup the Windows registry and settings in security software.
    *Do NOT remove personal data when you uninstall your current Firefox version, because all profile folders will be removed and you will also lose your personal data like bookmarks and passwords from profiles of other Firefox versions.
    Remove the Firefox program folder before installing that newly downloaded copy of the Firefox installer.
    *It is important to delete the Firefox program folder to remove all the files and make sure that there are no problems with files that were leftover after uninstalling.
    *http://kb.mozillazine.org/Uninstalling_Firefox
    Your bookmarks and other profile data are stored in the Firefox Profile Folder and won't be affected by an uninstall and (re)install, but make sure that "remove personal data" is NOT selected when you uninstall Firefox.
    *http://kb.mozillazine.org/Profile_folder_-_Firefox
    *http://kb.mozillazine.org/Profile_backup
    *http://kb.mozillazine.org/Standard_diagnostic_-_Firefox#Clean_reinstall

  • Doubt on try/catch exception object

    why it is not advisable to catch type exception in try catch block. Its confusing me. If i catch exception object then it will show whatever exception occured.
    btw, i was just go through duke stars how it works and saw this
    http://developers.sun.com/forums/top_10.jsp
    Congrats!

    Because there are many different kinds of Exception. If you have some specific local strategy for dealing with a particular excepion then you should be using a specific catch block.
    If you don't then you should allow the expection to end the program, and ideally you should deal with all the expceptions in one top-level handler, so you should throw, rather than catch the exceptions in your methods. Often at the outer most level of the program or thread you will actually catch Throwable (not just Exception) to deal with any unanticipated problems in a general kind of way.
    Also, you should be keeping track of what exceptions might be thrown, so that rather than using Exception in a throws clause or catch block, you should use the particular exceptions. Exceptions, generally, indicate a recoverable error that you really ought to be recovering from rather than just printing a stacktrace.
    That's why exceptions are treated differently from runtime errors.

  • Try catch exception handling

    Hi there,
    Was wondering if you could assist in me getting my head around try catch exception handling? I have this code:
    JOptionPane.showMessageDialog(null, "A subject consists of term names and definitions.\nYou should indicate the size and name of the subject");
             inputSubName = JOptionPane.showInputDialog(null, "Enter the Subject Name:");
             inputSubSize = JOptionPane.showInputDialog(null, "Enter the Subject's Term Size:");
             try {
                  size = Integer.parseInt(inputSubSize);
                  catch (NumberFormatException e) {
                            JOptionPane.showMessageDialog(null, "'" + inputSubSize + " is invalid " + " Please enter digits only");
                            inputSubSize = JOptionPane.showInputDialog(null, "Enter the Subject's Term Size:");
                            size = Integer.parseInt(inputSubSize);
             //create a new Subject object and pass in its name and size
             Subject sub = new Subject(inputSubName, size);
    ...My query is, if I catch an exception, how do I get the code to repeat the try again until the user inputs a correct data type? If the user above inputs something other than a number, it will catch it once and repeat the joptionpane inputbox, but if they do the same thing twice round - then the program bombs out. Is there a way i can get the code to retry the try until they input correctly?
    Cheers.

    eg.
    int size = 0;          
    while (true) {
         try {
              size = Integer.parseInt(inputSubSize);
              break;
         catch (NumberFormatException e) {
              JOptionPane.showMessageDialog(null, "'" + inputSubSize
                        + " is invalid " + " Please enter digits only");
              inputSubSize = JOptionPane.showInputDialog(null,
                        "Enter the Subject's Term Size:");
    }

  • Io Exception: Unknown host specified; fails for cluster, OK for one server

    SQL Developer 1.2.1.3213, BUILD MAIN-32.13, downloaded today, fails to connect to a remote two server Oracle cluster, until one of the two server DNS names and the comma between them is removed.
    FYI: The known host value looks like: devrac1.mydomain.ca,devrac2.mydomain.ca
    Change it to: devrac1.mydomain.ca and the connection will work as expected in 1.2.1
    Error dialog: "Error Connecting" An error was encountered performing the requested operation.
    "Io Exception: Unknown host specified"
    "Vendor code 17002"
    On SQL Developer version 1.1.0.15, build MAIN-15.57 all databases connect normally.
    The correct operation or failure apply to either Oracle 9i or 10g, on Windows XP Professional, SP 2, with JDK 6 update 3.
    Yours truly,
    Mike Rainville
    Version details:
    Oracle 9i, 9.2.0.0.0. or
    Oracle 10g, Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bi
    Microsoft Windows XP [Version 5.1.2600]
    java version "1.6.0_03"
    Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
    Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)
    (original post in thread: Re: Connecting to a remote database recreated here per your request)
    Mike Rainville
    Montreal, Canada

    You can also address both RAC nodes in your SQLDeveloper connection.
    Open the connection properties and select "Advanced" as "Connection Type".
    Use the following type of JDBC URL:
    jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=on)(ADDRESS=(PROTOCOL=tcp)(HOST=devrac1.mydomain.ca)(PORT=1521))(ADDRESS=(PROTOCOL=tcp)(HOST=devrac2.mydomain.ca)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=devrac.mydomain.ca)))
    Best,
    Manfred

Maybe you are looking for

  • Edit button not working on a publishing site on sub-level pages only (SP 2010)

    When I create a top level page, the Edit button/edit page works fine with checkout and checkin.  However, once I create a sub-level page - that is I create a second page within the first page then the edit button does not work and there is a message

  • Error -50 while trying to export my project

    Good evening, I built a 1h18 project. Then, I chose to delete not used plans from the associated event. As my project is too big to share it on my MobileMe gallery, I would like, either to share it in a smaller format, or to export it or to build a D

  • Import Organizations to SAP Business One

    Hi Everyone, I use BAPI and Batch-Import in order to import Organizations to SAP R/3 (SD). Today I've got the question whether the things would work in SAP Business One. I'm never heard about SAP Business One - just the customers asking whether our s

  • Text from Potential Spoofed #?

    I received an extremely rude / personal text message from a Miami, FL number that I don't know. The text contained information that could be discovered on social media (name of boyfriend /girlfriend) if the sender was a facebook friend, but otherwise

  • Adobe Uploading form error unknown file forma

    Hello, I am working on adobe form. I want to upload an form from another system using tranaction SFP and process menu 'UTILITIES UPLOADING FORM OBJECT'. I download the form from a environnement ECC6 in XML FILE. (by process downloading SFP transactio