File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQLException handling problem

 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 662
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any replies please.

Thanks.
 
Denis Spirin
Ranch Hand
Posts: 72
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have one question: How is it related to Sun Certified Java Developer Exam?
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wanted to see if any of you people had already come across this problem. Thats all.
 
Philippe Maquet
Bartender
Posts: 1872
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm moving this to the JDBC forum.

Regards,

Phil.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33689
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jayadev,
Are you using the same version of java are you using in WSAD and Websphere?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic