aspose file tools*
The moose likes JDBC and the fly likes SQLException handling problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQLException handling problem" Watch "SQLException handling problem" New topic
Author

SQLException handling problem

Jayadev Pulaparty
Ranch Hand

Joined: Mar 25, 2002
Posts: 662
Guys:

I'm having a weird problem with handling of SQLException. I have a caller method inside which i'm calling a called method. The code inside the called method includes some jdbc stuff and can potentially throw an SQLException.

Please see below -
*************************************************
Class A{

public void callerMethod(){

try{
new B().calledMethod();
..... // some other code here
}catch(SQLException sqle)
{
sqle.printStackTrace();
}
}

Class B{

public void calledMethod()throws SQLException{

try{
// some jdbc calls here
}catch(SQLException sqle)
{
throw sqle;
}
}
******************************************************

Now, the weird part is that the classes get compiled in WSAD environment, but not in standalone WebSphere AppServer environment, with the following error during compilation -

javac - callerMethod() "java.lang.Exception" should be handled or thrown
Jayadev Pulaparty
Ranch Hand

Joined: Mar 25, 2002
Posts: 662
Any replies please.

Thanks.
Denis Spirin
Ranch Hand

Joined: Mar 22, 2004
Posts: 72
I have one question: How is it related to Sun Certified Java Developer Exam?


Regards<br /> <br />Ph.D.<br />SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJD 2
Jayadev Pulaparty
Ranch Hand

Joined: Mar 25, 2002
Posts: 662
I wanted to see if any of you people had already come across this problem. Thats all.
Philippe Maquet
Bartender

Joined: Jun 02, 2003
Posts: 1872
I'm moving this to the JDBC forum.

Regards,

Phil.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30762
    
156

Jayadev,
Are you using the same version of java are you using in WSAD and Websphere?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQLException handling problem