1 22 package org.jboss.ejb3.test.regression.ejbthree290; 23 24 import java.sql.Connection ; 25 import java.sql.PreparedStatement ; 26 import javax.ejb.Stateless ; 27 import javax.ejb.TransactionAttribute ; 28 import javax.ejb.TransactionAttributeType ; 29 import javax.annotation.Resource; 30 import javax.sql.DataSource ; 31 32 38 @Stateless 39 public class DeleteBean implements DeleteLocal 40 { 41 @Resource(mappedName="java:/DefaultDS") DataSource ds; 42 43 @TransactionAttribute (TransactionAttributeType.REQUIRES_NEW) 44 public void removeEntity(int id) throws Exception 45 { 46 Connection conn = ds.getConnection(); 47 PreparedStatement ps = conn.prepareStatement("delete from MYENTITY_TABLE where id=?"); 48 ps.setInt(1, id); 49 ps.executeUpdate(); 50 ps.close(); 51 conn.close(); 52 } 53 } 54 | Popular Tags |