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 import java.util.ArrayList ; 29 import java.util.List ; 30 31 import org.continuent.sequoia.controller.recoverylog.LoggerThread; 32 33 40 public class GetAllBeginLoggedAfterIdEvent implements LogEvent 41 { 42 43 private Connection connection; 44 private String logTableName; 45 private long checkpointId; 46 private List beginList = null; 47 private SQLException catchedException = null; 48 private String logTableSqlColumnName; 49 50 58 public GetAllBeginLoggedAfterIdEvent(Connection connection, 59 String logTableName, String logTableSqlColumnName, long checkpointId) 60 { 61 this.connection = connection; 62 this.logTableName = logTableName; 63 this.checkpointId = checkpointId; 64 this.logTableSqlColumnName = logTableSqlColumnName; 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 transaction_id FROM " 85 + logTableName + " WHERE log_id>? AND " + logTableSqlColumnName 86 + " LIKE ?"); 87 stmt.setLong(1, checkpointId); 88 stmt.setString(2, "begin"); 89 rs = stmt.executeQuery(); 90 beginList = new ArrayList (); 91 while (rs.next()) 92 beginList.add(new Long (rs.getLong(1))); 93 } 94 catch (SQLException e) 95 { 96 catchedException = e; 97 } 98 finally 99 { 100 try 101 { 102 if (rs != null) 103 rs.close(); 104 } 105 catch (Exception ignore) 106 { 107 } 108 try 109 { 110 if (stmt != null) 111 stmt.close(); 112 } 113 catch (Exception ignore) 114 { 115 } 116 synchronized (this) 117 { 118 notify(); 119 } 120 } 121 } 122 123 129 public final SQLException getCatchedException() 130 { 131 return catchedException; 132 } 133 134 140 public List getBeginList() throws SQLException 141 { 142 if (beginList == null) 143 throw catchedException; 144 return beginList; 145 } 146 147 150 public String toString() 151 { 152 return "GetCheckpointLogIdEvent for checkpoint " + checkpointId; 153 } 154 155 } 156 | Popular Tags |