make rollback() and throw a exception

O

ojvm

hi to everybody. tanks in advance for take some of your time to read
this.


ok the cuestion is simple. a class makes a transaction and throw a
exception (SQLException) so, in jsp i make a instance of that class,
because the class throws a exception it must be catch in the jsp.
The problem is when a exception occurs in the class if i catch the
exception in the same class in the jsp i can't see the error, so how
can i make a rollback in the class and still see the error en the
page??

ok this is how it works

---jsp----

try{
MyClass c = new MyClass();
}catch(SQLException e){
out.println("error number..." + e.getErrorCode());
}

--class--
//cn is a valid Connection;
try{
cn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
cn.setAutoCommit(false);

make some code...

cn.commit();
}catch(SQLException e){
//if a error occurs make the rollback()
cn.rollback();
}

with this code the error stays here, in this class.

i hope someone can help me.
 
S

Stefan Schulz

//cn is a valid Connection;
try{
cn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
cn.setAutoCommit(false);

make some code...

cn.commit();
}catch(SQLException e){
//if a error occurs make the rollback()
cn.rollback();

throw e;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top