Results 1 to 1 of 1
- 02-25-2011, 05:48 AM #1
Member
- Join Date
- Feb 2011
- Posts
- 2
- Rep Power
- 0
Exception Handling for failed connection
Hello again, i have this code working fine.
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..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);
thanks,
So far im using
I would like to know a more efficient way though.Java Code:int errorCode = sR.getResponseCode(); if(errorCode == 200) { //do stuff here } else{}//when its 401 do nothingLast edited by jmorr212; 02-25-2011 at 05:51 AM.
Similar Threads
-
Exception Handling
By eLancaster in forum New To JavaReplies: 4Last Post: 02-20-2011, 12:00 AM -
JDBC connection failed to oracle 10g can anyone help
By Navatha in forum Advanced JavaReplies: 1Last Post: 11-11-2010, 08:58 AM -
Exception Handling
By liljester in forum New To JavaReplies: 4Last Post: 06-21-2010, 03:09 PM -
urgent help -java mail authorization failed exception
By ravinder.kadiyan in forum Advanced JavaReplies: 2Last Post: 04-30-2008, 11:27 AM -
Exception Failed to Generate Wrapper Class on WebLogic
By christina in forum New To JavaReplies: 1Last Post: 08-07-2007, 02:15 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks