jQuery in Action, 2nd edition
The moose likes JDBC and the fly likes SQLException handling problem Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "SQLException handling problem" Watch "SQLException handling problem" New topic
Author

SQLException handling problem

Jayadev Pulaparty
Ranch Hand

Joined: Mar 25, 2002
Posts: 645
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: 645
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: 645
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 26144
    
  66

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
 
Similar Threads
Another code snippet about SQLException
Could not locate DB driver
Design implementation Doubt Please tell me the best approach
Is ths Transaction Handling Write or Wrong ?
Exception handling in finally block