1 21 22 package org.apache.derby.client; 23 24 import java.sql.PreparedStatement ; 25 import java.sql.SQLException ; 26 import java.util.Enumeration ; 27 import java.util.Vector ; 28 import javax.sql.StatementEvent ; 29 import javax.sql.StatementEventListener ; 30 import org.apache.derby.client.am.SqlException; 31 import org.apache.derby.client.net.NetLogWriter; 32 import org.apache.derby.client.net.NetXAConnection; 33 import org.apache.derby.jdbc.ClientDataSource; 34 import org.apache.derby.jdbc.ClientXADataSource; 35 36 39 public class ClientXAConnection40 extends ClientXAConnection { 40 41 protected final Vector <StatementEventListener > statementEventListeners = 43 new Vector <StatementEventListener >(); 44 45 46 53 public ClientXAConnection40 (ClientXADataSource ds, 54 org.apache.derby.client.net.NetLogWriter logWtr, 55 String userId, 56 String password) throws SQLException { 57 super(ds, logWtr, userId, password); 58 } 59 60 61 72 public void removeStatementEventListener(StatementEventListener listener) { 73 if (logWriter_ != null) { 74 logWriter_.traceEntry(this, "removeConnectionEventListener", listener); 75 } 76 statementEventListeners.removeElement(listener); 77 } 78 79 91 public void addStatementEventListener(StatementEventListener listener) { 92 if (logWriter_ != null) { 93 logWriter_.traceEntry(this, "addStatementEventListener", listener); 94 } 95 statementEventListeners.addElement(listener); 96 } 97 98 103 public void onStatementClose(PreparedStatement statement) { 104 if (!statementEventListeners.isEmpty()) { 105 StatementEvent event = new StatementEvent (this,statement); 106 synchronized(statementEventListeners) { 109 for (StatementEventListener l : statementEventListeners) { 110 l.statementClosed(event); 111 } 112 } 113 } 114 } 115 116 126 public void onStatementErrorOccurred(PreparedStatement statement, 127 SQLException sqle) { 128 if (!statementEventListeners.isEmpty()) { 129 StatementEvent event = new StatementEvent (this,statement,sqle); 130 synchronized(statementEventListeners) { 133 for (StatementEventListener l : statementEventListeners) { 134 l.statementErrorOccurred(event); 135 } 136 } 137 } 138 } 139 } 140 | Popular Tags |