-
1. Re: The lifetime of a transaction in EJB
sfcoy Oct 4, 2013 3:38 AM (in response to kozachuk-v)How is this particular operation started?
Is it imperative that the whole operation be completed within a single transaction? In other words is a rollback required if there is a failure?
-
2. Re: The lifetime of a transaction in EJB
kozachuk-v Oct 5, 2013 2:21 AM (in response to sfcoy)Thank you. I'm not completely given issue
@Resource(mappedName = "java:jboss/datasources/blackBoxDS", type = DataSource.class)
private DataSource dataSource;
private Connection dbConnection;
private Statement statement;
...
private void readF(File file){
byte b [] = new byte[32];
int row=0;
try {
dbConnection = dataSource.getConnection();
statement = dbConnection.createStatement();
dbConnection.setAutoCommit(false);
while (inStm.available()>=32){
row++;
inStm.read(b);
Event rEv= new Event(b)
sql = new String("INSERT INTO tabl_ (DDateTime,Fileld_) VALUE('"+rEv.getDate()+"',"+rEv.binToint(10,24)+")");
statement.executeUpdate(sql);
if (row % 2000 == 0) dbConnection.commit();
}
if (row % 2000 != 0) dbConnection.commit();
inStm.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
addition occurs on 2000 row. After 3 minutes of work I was getting error. After the decision was no change to the file standalone.xml. However, it applies to all transactions. how to extend this particular transaction, this method is?
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
@TransactionTimeout(value = 1, unit = TimeUnit.HOURS)
Annotations as I understand it does not work here.