File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Question on Unhandled Exception - please help! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Question on Unhandled Exception - please help!" Watch "Question on Unhandled Exception - please help!" New topic
Author

Question on Unhandled Exception - please help!

Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 386

In my code I have a method whereby I am trying to connect either to a local server or a mainframe (only this first if statement is shown) but in the BOLDED line below I am getting a "Unhandled exception type ClassNotFoundException". Any help or direction would be appreciated.

Here is my code:

Maximilian Xavier Stocker
Ranch Hand

Joined: Sep 20, 2005
Posts: 381
Class.forName throws ClassNotFoundException

So you need to catch it. Or have your method declare that it throws it.
Melinda Savoy
Ranch Hand

Joined: Jun 21, 2005
Posts: 386

Thanks for the reply.

I guess what I don't understand is why I am getting this error. Before putting the if statement around this statement within the try catch I did not get this error. Is it only because I put it in an IF statement? This file is already in the classpath so I do not understand WHY this error now came up.

Any insight would be appreciated.

Thanks again.
Maximilian Xavier Stocker
Ranch Hand

Joined: Sep 20, 2005
Posts: 381
There is more to it than the if statement. If you had the Class forName before then you must have made some other subtle change that gave it problems. Like you used to catch Exception and now you catch SQLException or you used to throws Exception in the method signature but now you only throw SQLException.

Something else changed. Class.forName throws ClassNotFoundException. It did before and it does now. So there was something else other than the if that meant that it wasn't a problem but now it is.
 
jQuery in Action, 2nd edition
 
subject: Question on Unhandled Exception - please help!
 
Similar Threads
Newbie help please on SQL connection problem
Help needed on SQL Server Error
idiom for finally closing resources
Getting Connection Establishing in Linux Server
Insert date and time into Oracle database