1 23 24 package org.objectweb.cjdbc.controller.recoverylog.events; 25 26 import java.sql.PreparedStatement ; 27 import java.sql.SQLException ; 28 29 import org.objectweb.cjdbc.common.i18n.Translate; 30 import org.objectweb.cjdbc.common.log.Trace; 31 import org.objectweb.cjdbc.controller.recoverylog.LoggerThread; 32 33 39 public class UnlogRequestEvent implements LogEvent 40 { 41 private LogEntry logEntry; 42 43 48 public UnlogRequestEvent(LogEntry entry) 49 { 50 if (entry == null) 51 throw new RuntimeException ( 52 "Invalid null entry in UnlogRequestEvent constructor"); 53 this.logEntry = entry; 54 } 55 56 59 public boolean belongToTransaction(long tid) 60 { 61 return logEntry.getTid() == tid; 62 } 63 64 67 public void execute(LoggerThread loggerThread) 68 { 69 Trace logger = loggerThread.getLogger(); 70 try 71 { 72 if (logger.isInfoEnabled()) 73 logger.info(Translate.get("recovery.jdbc.loggerthread.unlog.info", 74 logEntry.getId())); 75 76 PreparedStatement pstmt = loggerThread.getUnlogPreparedStatement(); 77 pstmt.setLong(1, logEntry.getId()); 78 pstmt.setString(2, logEntry.getLogin()); 79 pstmt.setString(3, logEntry.getQuery()); 80 pstmt.setLong(4, logEntry.getTid()); 81 if (logger.isDebugEnabled()) 82 logger.debug(pstmt.toString()); 83 84 try 85 { 86 pstmt.setEscapeProcessing(logEntry.getEscapeProcessing()); 87 } 88 catch (Exception ignore) 89 { 90 } 91 int updatedRows = pstmt.executeUpdate(); 92 if ((updatedRows != 1) && logger.isWarnEnabled()) 93 logger 94 .warn("Recovery log did not update a single entry while executing: " 95 + pstmt.toString()); 96 } 97 catch (SQLException e) 98 { 99 loggerThread.invalidateLogStatements(); 100 logger.error( 101 Translate.get("recovery.jdbc.loggerthread.log.failed", new String []{ 102 logEntry.getQuery(), String.valueOf(logEntry.getTid())}), e); 103 loggerThread.putBackAtHeadOfQueue(this); 105 } 106 } 107 108 } 109 | Popular Tags |