Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQLException handling problem

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

Thanks.
 
Denis Spirin
Ranch Hand
Posts: 72
  • 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
  • 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
  • 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: 34839
369
Eclipse IDE Java VI Editor
  • 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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic