File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes How can I solve this problem?!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How can I solve this problem?!!" Watch "How can I solve this problem?!!" New topic
Author

How can I solve this problem?!!

Elahe Shafie
Ranch Hand

Joined: Dec 12, 2001
Posts: 291
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

Joined: Mar 22, 2002
Posts: 1055
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

Joined: Dec 10, 2001
Posts: 7023
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 ]

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can I solve this problem?!!