Simple exception chaining problem

The problem is 'throw new ClientException(e.getMessage());' the error message kept stating to be in try/catch but it's already in try bracklet. I tried placing the exception in other bracklet but it defeats the purpose of showing the exception in this specific bracklet. I'm not sure what's the solution of this, I got the two solutions in netbeans - make a new try/catch or extending the exception. I looked at the book, I don't see this class extending anything.

import java.sql.Connection;

import java.sql.SQLException;

publicclass ClientBO{

private Connection con;

/** Creates a new instance of ClientBO */

public ClientBO(){

con = TomcatDAOFactory.createConnection();

}

publicvoid addSheet(SheetsForm sheetsform){

Connection con =null;

try{

TomcatClientDAO tomcatclientdao =new TomcatClientDAO(con);

tomcatclientdao.createTest(sheetsform);

con.commit();

}catch (Exception e){

try{

if (con !=null){

con.rollback();

thrownew ClientException(e.getMessage());

}

}catch (SQLException sqle){

e.printStackTrace();

thrownew RuntimeException("error.unexpected");

}

}finally{

try{

if (con !=null){

con.close();

}

}catch (SQLException sqle){

sqle.printStackTrace();

thrownew RuntimeException("error.unexpected");

}

}

}

}

[3072 byte] By [Meepa] at [2007-11-27 10:51:20]
# 1

You declare this:

private Connection con;

and define it in this constructor.

public ClientBO()

Next you declare this:

Connection con = null;

every line below this statement uses this locally defined variable 'conn',

not the class variable 'conn' declared in 'private Connection con' (got that?). So from that point on , conn is null.

Also, see my example on:

http://forum.java.sun.com/thread.jspa?threadID=5193839&messageID=9769059#9769059

George123a at 2007-7-29 11:30:35 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...