final DataSource ds = DataSourceLocator.getInstance()
.getDataSource(sg.cmpl.starhub.lprs.Constants.APP_KEY);
final DataSourceTransactionManager txManager = new DataSourceTransactionManager();
txManager.setDataSource(ds);
final DefaultTransactionDefinition def = new DefaultTransactionDefinition();
def.setIsolationLevel(TransactionDefinition.ISOLATION_READ_COMMITTED);
final TransactionStatus status = txManager.getTransaction(def);
Connection conn = null;
PreparedStatement ps = null;
try {
/***************************************************************************/
conn = DataSourceUtils.getConnection(ds);
ps = conn.prepareStatement(sql);
ps.execute();
/***************************************************************************/
txManager.commit(status);
} catch (Exception e) {
txManager.rollback(status);
}
Is there something wrong with my transaction manager logic? It looks like unstable. When I insert new data, First time it seems to save and later I can't find the data in mysql database. Please help. Thanks a lot.