• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can I solve this problem?!!

 
Elahe Shafie
Ranch Hand
Posts: 291
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,
I am faceing this error which says I have to use try...catch I guess if Iput my codes in try block so I do not have any thing to catch?! what should I put in catch block?
Here is what I think to do but I think it is wrong could you please help me on this?at the end you can see the original code as well
Many thanks,
Elahe

Error
=======
Exception java.sql.SQLException thrown from addUserList must be caught, or it must be declared in the throws clause of this method
addUserList( ctx );
^
Exception java.sql.SQLException thrown from addStatusNameList must be caught, or it must be declared in the throws clause of this method
addStatusNameList( ctx );
^
2 errors
 
Anthony Villanueva
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by elahe shafie:
Here is what I think to do but I think it is wrong could you please help me on this?


Actually, you're on the right track. Here's a hint: catch and rethrow.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The concept of handling checked exceptions is very basic to exception handling in Java. I recommend taking a look at The Exception Handling Section of Sun's Java Tutorial and chapters 80-81 of Bradley Kjell's Introduction to Computer Science using Java.
Concerning the compilation errors, you gotta do what the compiler said you gotta do. You could catch and handle the exceptions:or you could declare that your method just throws them
[ August 25, 2002: Message edited by: Dirk Schreckmann ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic