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 LogRequestEvent implements LogEvent 40 { 41 protected LogEntry logEntry; 42 43 48 public LogRequestEvent(LogEntry entry) 49 { 50 if (entry == null) 51 throw new RuntimeException ( 52 "Invalid null entry in LogRequestEvent 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.log.info", 74 logEntry.getId())); 75 76 PreparedStatement pstmt = loggerThread.getLogPreparedStatement(); 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 try 84 { 85 pstmt.setEscapeProcessing(logEntry.getEscapeProcessing()); 86 } 87 catch (Exception ignore) 88 { 89 } 90 int updatedRows = pstmt.executeUpdate(); 91 if ((updatedRows != 1) && logger.isWarnEnabled()) 92 logger 93 .warn("Recovery log did not update a single entry while executing: " 94 + pstmt.toString()); 95 } 96 catch (SQLException e) 97 { 98 loggerThread.invalidateLogStatements(); 99 logger.error( 100 Translate.get("recovery.jdbc.loggerthread.log.failed", new String []{ 101 logEntry.getQuery(), String.valueOf(logEntry.getTid())}), e); 102 loggerThread.putBackAtHeadOfQueue(this); 104 } 105 } 106 107 } 108 | Popular Tags |