You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@beehive.apache.org by Scott Semyan <se...@bea.com> on 2005/05/12 19:45:55 UTC
Problem using transactions with JDBC control
I have a new error in the PetStore web sample. I have a section of code
that uses a transaction to add something to the database. I initially
enabled this with the following code:
public int addOrder(Order order, Cart cart)
{
try {
java.sql.Connection connection = _dbControl.getConnection();
connection.setAutoCommit( false );
// Add order to DB
// Add the cart items and update the quantities in the DB
//connection.commit();
} catch (SQLException e) {
_logger.error( "Unexpected DAO exception", e );
throw new DataStoreException("unexpected database exception");
}
return orderId;
}
This used to work fine. Now when I do it, the order is added correctly,
but the subsequent call to the database (to read the contents of the
order just entered) generates the following:
Exception: org.apache.beehive.controls.api.ControlException: SQL
Exception while attempting to close database connection.[Invalid
transaction state.]
caused by : SQL Exception: Invalid transaction state.
Did anything change recently? Is this the proper way to do transactions
with the JDBC control?
Scott Semyan