1 20 21 22 package org.apache.derby.jdbc; 23 24 import java.util.Vector ; 25 import java.sql.PreparedStatement ; 26 import java.sql.SQLException ; 27 import javax.sql.StatementEvent ; 28 import javax.sql.StatementEventListener ; 29 import javax.sql.XAConnection ; 30 import org.apache.derby.iapi.jdbc.ResourceAdapter; 31 32 35 final class EmbedXAConnection40 extends EmbedXAConnection 36 implements XAConnection { 37 38 protected final Vector <StatementEventListener > statementEventListeners = 40 new Vector <StatementEventListener >(); 41 42 50 EmbedXAConnection40 (EmbeddedDataSource ds, ResourceAdapter ra, 51 String user, String password, 52 boolean requestPassword) throws SQLException { 53 super(ds, ra, user, password, requestPassword); 54 } 55 67 public void removeStatementEventListener(StatementEventListener listener) { 68 if (listener == null) 69 return; 70 statementEventListeners.removeElement(listener); 71 } 72 73 88 public void addStatementEventListener(StatementEventListener listener) { 89 if (!isActive) 90 return; 91 if (listener == null) 92 return; 93 statementEventListeners.addElement(listener); 94 } 95 96 101 public void onStatementClose(PreparedStatement statement) { 102 if (!statementEventListeners.isEmpty()){ 103 StatementEvent event = new StatementEvent (this,statement); 104 synchronized(statementEventListeners) { 107 for (StatementEventListener l : statementEventListeners) { 108 l.statementClosed(event); 109 } 110 } 111 } 112 } 113 114 120 public void onStatementErrorOccurred(PreparedStatement statement,SQLException sqle) { 121 if (!statementEventListeners.isEmpty()){ 122 StatementEvent event = new StatementEvent (this,statement,sqle); 123 synchronized(statementEventListeners) { 126 for (StatementEventListener l : statementEventListeners){ 127 l.statementErrorOccurred(event); 128 } 129 } 130 } 131 } 132 133 } | Popular Tags |