@Override protected Connection getConnection() throws SQLException { Connection conn = null; while (conn == null) { try { conn = DriverManager.getConnection(url, userProps); } catch (SQLException r) { logger.severe("Could not connect: " + r.getMessage()); } } setModule(conn, moduleName); DemoHelper.logSessionInfo(conn, serviceName, moduleName, program); return conn; }
@Override public boolean process(Transaction transaction) throws SQLException { boolean done = false; int tries = 0; Connection conn = getConnection(); while (!done && tries <= MAXRETRIES) { try { logger.info("Starting transaction."); transaction.execute(conn); if (ORA_14906) { DemoHelper.ORA_14906(conn); } logger.info("Work done. Now going to commit!"); conn.commit(); conn.close(); done = true; } catch (SQLRecoverableException e) { try { conn.close(); } catch (Exception ex) { } LogicalTransactionId ltxid = ((OracleConnection) conn).getLogicalTransactionId(); logger.info("transaction failed: ltxid is: " + byteArrayToHexString(ltxid.getBytes())); logger.info("Exception was: " + e.getMessage()); Connection newconn = getConnection(); setModule(newconn, moduleName); done = isLTxIdCommitted(ltxid, newconn); if (done) { logger.info("Failed transaction had already been committed."); } else { logger.info("Replay of transaction neccessary."); tries++; conn = newconn; } } } return true; }