Results 1 to 1 of 1
  1. #1
    jmorr212 is offline Member
    Join Date
    Feb 2011
    Posts
    2
    Rep Power
    0

    Default Exception Handling for failed connection

    Hello again, i have this code working fine.
    Java Code:
    sR = (HttpsURLConnection)daLogin.openConnection();          
                sR.setRequestProperty("Authorization",
                "Passport1.4 OrgVerb=GET,OrgURL=http%3A%2F    %2Fmessenger%2Emsn%2Ecom,sign-in=" +
                uN.replaceAll("@", "%40") + ",pwd=" + pW+ "," + cS);
    The only problem is the exception handling, this connects to the msn server. If the username(uN) or password(pW) are incorrect, i want it to throw some form of exception so that the next few lines or code are not executed. I am unsure of such an exception though? I can use getResponseCode() to see whether its 200(authorized) 401(unauthorized) but even if it returns 401 it doesnt throw any error. I tried HTTPException and it didnt work..

    thanks,

    So far im using
    Java Code:
    int errorCode = sR.getResponseCode();
    if(errorCode == 200)
    {
     //do stuff here
    }
    else{}//when its 401 do nothing
    I would like to know a more efficient way though.
    Last edited by jmorr212; 02-25-2011 at 05:51 AM.

Similar Threads

  1. Exception Handling
    By eLancaster in forum New To Java
    Replies: 4
    Last Post: 02-20-2011, 12:00 AM
  2. JDBC connection failed to oracle 10g can anyone help
    By Navatha in forum Advanced Java
    Replies: 1
    Last Post: 11-11-2010, 08:58 AM
  3. Exception Handling
    By liljester in forum New To Java
    Replies: 4
    Last Post: 06-21-2010, 03:09 PM
  4. urgent help -java mail authorization failed exception
    By ravinder.kadiyan in forum Advanced Java
    Replies: 2
    Last Post: 04-30-2008, 11:27 AM
  5. Exception Failed to Generate Wrapper Class on WebLogic
    By christina in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 02:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •