1 21 22 package org.continuent.sequoia.controller.recoverylog.events; 23 24 import java.sql.Connection ; 25 import java.sql.PreparedStatement ; 26 import java.sql.ResultSet ; 27 import java.sql.SQLException ; 28 29 import org.continuent.sequoia.common.i18n.Translate; 30 import org.continuent.sequoia.controller.recoverylog.LoggerThread; 31 import org.continuent.sequoia.controller.recoverylog.RecoveryLog; 32 33 43 public class FindCommitEvent implements LogEvent 44 { 45 private Connection connection; 46 private RecoveryLog recoveryLog; 47 private long transactionId; 48 private boolean found = false; 49 private String status = LogEntry.MISSING; 50 private SQLException catchedException = null; 51 52 59 public FindCommitEvent(Connection connection, RecoveryLog recoveryLog, 60 long requestId) 61 { 62 this.connection = connection; 63 this.recoveryLog = recoveryLog; 64 this.transactionId = requestId; 65 } 66 67 70 public boolean belongToTransaction(long tid) 71 { 72 return false; 73 } 74 75 78 public void execute(LoggerThread loggerThread) 79 { 80 PreparedStatement stmt = null; 81 ResultSet rs = null; 82 try 83 { 84 stmt = connection.prepareStatement("SELECT exec_status FROM " 85 + recoveryLog.getLogTableName() + " WHERE ((transaction_id=?) AND (" 86 + recoveryLog.getLogTableSqlColumnName() + "='commit'))"); 87 stmt.setLong(1, transactionId); 88 rs = stmt.executeQuery(); 89 90 found = rs.next(); 92 if (found) 93 status = rs.getString(1); 94 } 95 catch (SQLException e) 96 { 97 catchedException = new SQLException (Translate.get( 98 "recovery.jdbc.commit.not.found.error", new Object []{ 99 new Long (transactionId), e.getMessage()})); 100 } 101 finally 102 { 103 try 104 { 105 if (rs != null) 106 rs.close(); 107 } 108 catch (Exception ignore) 109 { 110 } 111 try 112 { 113 if (stmt != null) 114 stmt.close(); 115 } 116 catch (Exception ignore) 117 { 118 } 119 synchronized (this) 120 { 121 notify(); 122 } 123 } 124 } 125 126 132 public final SQLException getCatchedException() 133 { 134 return catchedException; 135 } 136 137 143 public String getStatus() 144 { 145 return status; 146 } 147 148 153 public boolean wasFound() 154 { 155 return found; 156 } 157 158 161 public String toString() 162 { 163 return "FindCommitEvent for request ID " + transactionId; 164 } 165 } 166 | Popular Tags |