1 21 22 package org.apache.derby.jdbc; 23 24 import java.sql.Connection ; 25 import java.sql.SQLException ; 26 import java.util.Enumeration ; 27 import java.util.Vector ; 28 import java.sql.PreparedStatement ; 29 import javax.sql.StatementEvent ; 30 import javax.sql.StatementEventListener ; 31 32 43 class EmbedPooledConnection40 extends EmbedPooledConnection { 44 45 protected final Vector <StatementEventListener > statementEventListeners = 47 new Vector <StatementEventListener >(); 48 49 50 EmbedPooledConnection40 (ReferenceableDataSource ds, String user, 51 String password, boolean requestPassword) throws SQLException { 52 super (ds, user, password, requestPassword); 53 } 54 66 public void removeStatementEventListener(StatementEventListener listener) { 67 if (listener == null) 68 return; 69 statementEventListeners.removeElement(listener); 70 } 71 72 87 public void addStatementEventListener(StatementEventListener listener) { 88 if (!isActive) 89 return; 90 if (listener == null) 91 return; 92 statementEventListeners.addElement(listener); 93 } 94 95 100 public void onStatementClose(PreparedStatement statement) { 101 if (!statementEventListeners.isEmpty()){ 102 StatementEvent event = new StatementEvent (this,statement); 103 synchronized(statementEventListeners) { 106 for (StatementEventListener l : statementEventListeners) { 107 l.statementClosed(event); 108 } 109 } 110 } 111 } 112 113 119 public void onStatementErrorOccurred(PreparedStatement statement,SQLException sqle) { 120 if (!statementEventListeners.isEmpty()){ 121 StatementEvent event = new StatementEvent (this,statement,sqle); 122 synchronized(statementEventListeners) { 125 for (StatementEventListener l : statementEventListeners){ 126 l.statementErrorOccurred(event); 127 } 128 } 129 } 130 } 131 } 132 | Popular Tags |