/**
* @param args
*/
public static void main(String[] args) throws Exception {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("context.xml", TestSpringTxnStuff.class);
PlatformTransactionManager txnManager =ctx.getBean(PlatformTransactionManager.class);
DataSource dataSource = ctx.getBean(DataSource.class);
JdbcTemplate jdbcTemplate = new JdbcTemplate();
jdbcTemplate.setDataSource(dataSource);
TransactionStatus status = txnManager.getTransaction(new DefaultTransactionDefinition());
try {
long id = 1;
jdbcTemplate.execute("DELETE FROM COP_AUDIT_TRAIL_EVENT");
System.out.println("wait #1");
Thread.sleep(10000);
doTransactional(dataSource, "INSERT INTO COP_AUDIT_TRAIL_EVENT (SEQ_ID, OCCURRENCE, CONVERSATION_ID, LOGLEVEL, CONTEXT, LONG_MESSAGE) VALUES ("+(id++)+", SYSTIMESTAMP, '123', 1, 'CTX', 'Hello World!')");
doTransactional(dataSource, "INSERT INTO COP_AUDIT_TRAIL_EVENT (SEQ_ID, OCCURRENCE, CONVERSATION_ID, LOGLEVEL, CONTEXT, LONG_MESSAGE) VALUES ("+(id++)+", SYSTIMESTAMP, '123', 1, 'CTX', 'Hello World!')");
System.out.println("wait #2");
Thread.sleep(10000);
}
catch(Exception e) {
txnManager.rollback(status);
throw e;
}
txnManager.commit(status);
System.out.println("wait #3");
Thread.sleep(10000);
}