Hi,friends
When i set the session bean's transaction attribute as "Container" ,it will throw "cannot commit transactional connection" as below:
...
public void updateCoffees(RowSet rs) throws SQLException
{
Connection con = null;
PreparedStatement stmt = null;
try {
CachedRowSet crs = (CachedRowSet)rs;
// moves the changes back to the database
con = getConnection();
crs.acceptChanges(con);
}catch(Exception e) {
EJBException re = new EJBException(e.getMessage());
throw re;
}
finally {
if (stmt != null) stmt.close();
if (con != null) con.close();
}
}
The errro is caused by acceptChanges() because there is no error when replaced with the following code:
...
stmt = con.prepareStatement("update coffees set PRICE=? where COF_NAME = ?"
;
stmt.setDouble(1, 100.00);
stmt.setString(2,"Columbian"
;
stmt.executeUpdate();
...
Cannot i use rowset in a CMT bean ?
IPO_z@cmmail.com
Garbage in,Garbage out
When i set the session bean's transaction attribute as "Container" ,it will throw "cannot commit transactional connection" as below:
...
public void updateCoffees(RowSet rs) throws SQLException
{
Connection con = null;
PreparedStatement stmt = null;
try {
CachedRowSet crs = (CachedRowSet)rs;
// moves the changes back to the database
con = getConnection();
crs.acceptChanges(con);
}catch(Exception e) {
EJBException re = new EJBException(e.getMessage());
throw re;
}
finally {
if (stmt != null) stmt.close();
if (con != null) con.close();
}
}
The errro is caused by acceptChanges() because there is no error when replaced with the following code:
...
stmt = con.prepareStatement("update coffees set PRICE=? where COF_NAME = ?"
stmt.setDouble(1, 100.00);
stmt.setString(2,"Columbian"
stmt.executeUpdate();
...
Cannot i use rowset in a CMT bean ?
IPO_z@cmmail.com
Garbage in,Garbage out