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.ConnectionEventListener ; 29 import javax.sql.StatementEventListener ; 30 import javax.sql.StatementEvent ; 31 import org.apache.derby.client.am.SqlException; 32 import org.apache.derby.client.net.NetXAConnection; 33 import org.apache.derby.jdbc.ClientBaseDataSource; 34 import org.apache.derby.jdbc.ClientDataSource; 35 import org.apache.derby.client.am.SqlException; 36 import org.apache.derby.client.net.NetLogWriter; 37 38 45 46 public class ClientPooledConnection40 extends ClientPooledConnection { 47 protected final Vector <StatementEventListener > statementEventListeners = 49 new Vector <StatementEventListener >(); 50 51 public ClientPooledConnection40(ClientBaseDataSource ds, 52 org.apache.derby.client.am.LogWriter logWriter, 53 String user, 54 String password) throws SQLException { 55 super(ds,logWriter,user,password); 56 57 } 58 59 60 public ClientPooledConnection40(ClientBaseDataSource ds, 61 org.apache.derby.client.am.LogWriter logWriter, 62 String user, 63 String password, 64 int rmId) throws SQLException { 65 super(ds,logWriter,user,password,rmId); 66 67 } 68 69 public ClientPooledConnection40(ClientBaseDataSource ds, 70 org.apache.derby.client.am.LogWriter logWriter) throws SQLException { 71 super(ds,logWriter); 72 } 73 74 86 public void addStatementEventListener(StatementEventListener listener){ 87 if (logWriter_ != null) { 88 logWriter_.traceEntry(this, "addStatementEventListener", listener); 89 } 90 statementEventListeners.addElement(listener); 91 } 92 93 102 public void removeStatementEventListener(StatementEventListener listener){ 103 if (logWriter_ != null) { 104 logWriter_.traceEntry(this, "removeConnectionEventListener", listener); 105 } 106 statementEventListeners.removeElement(listener); 107 } 108 109 117 public void onStatementClose(PreparedStatement statement) { 118 if (!statementEventListeners.isEmpty()) { 119 StatementEvent event = new StatementEvent (this,statement); 120 synchronized(statementEventListeners) { 123 for (StatementEventListener l : statementEventListeners) { 124 l.statementClosed(event); 125 } 126 } 127 } 128 } 129 130 140 public void onStatementErrorOccurred(PreparedStatement statement, 141 SQLException sqle) { 142 if (!statementEventListeners.isEmpty()) { 143 StatementEvent event = new StatementEvent (this,statement,sqle); 144 synchronized(statementEventListeners) { 147 for (StatementEventListener l : statementEventListeners) { 148 l.statementErrorOccurred(event); 149 } 150 } 151 } 152 } 153 } 154 | Popular Tags |