1 /* 2 * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 /* 27 * Created on Apr 28, 2005 28 */ 29 package javax.sql; 30 31 import java.sql.PreparedStatement; 32 import java.sql.SQLException; 33 import java.util.EventObject; 34 35 /** 36 * A <code>StatementEvent</code> is sent to all <code>StatementEventListener</code>s which were 37 * registered with a <code>PooledConnection</code>. This occurs when the driver determines that a 38 * <code>PreparedStatement</code> that is associated with the <code>PooledConnection</code> has been closed or the driver determines 39 * is invalid. 40 * <p> 41 * @since 1.6 42 */ 43 public class StatementEvent extends EventObject { 44 45 private SQLException exception; 46 private PreparedStatement statement; 47 48 /** 49 * Constructs a <code>StatementEvent</code> with the specified <code>PooledConnection</code> and 50 * <code>PreparedStatement</code>. The <code>SQLException</code> contained in the event defaults to 51 * null. 52 * <p> 53 * @param con The <code>PooledConnection</code> that the closed or invalid 54 * <code>PreparedStatement</code>is associated with. 55 * @param statement The <code>PreparedStatement</code> that is bieng closed or is invalid 56 * <p> 57 * @throws IllegalArgumentException if <code>con</code> is null. 58 * 59 * @since 1.6 60 */ 61 public StatementEvent(PooledConnection con, 62 PreparedStatement statement) { 63 64 super(con); 65 66 this.statement = statement; 67 this.exception = null; 68 } 69 70 /** 71 * Constructs a <code>StatementEvent</code> with the specified <code>PooledConnection</code>, 72 * <code>PreparedStatement</code> and <code>SQLException</code> 73 * <p> 74 * @param con The <code>PooledConnection</code> that the closed or invalid <code>PreparedStatement</code> 75 * is associated with. 76 * @param statement The <code>PreparedStatement</code> that is being closed or is invalid 77 * @param exception The <code>SQLException </code>the driver is about to throw to 78 * the application 79 * 80 * @throws IllegalArgumentException if <code>con</code> is null. 81 * <p> 82 * @since 1.6 83 */ 84 public StatementEvent(PooledConnection con, 85 PreparedStatement statement, 86 SQLException exception) { 87 88 super(con); 89 90 this.statement = statement; 91 this.exception = exception; 92 } 93 94 /** 95 * Returns the <code>PreparedStatement</code> that is being closed or is invalid 96 * <p> 97 * @return The <code>PreparedStatement</code> that is being closed or is invalid 98 * <p> 99 * @since 1.6 100 */ 101 public PreparedStatement getStatement() { 102 103 return this.statement; 104 } 105 106 /** 107 * Returns the <code>SQLException</code> the driver is about to throw 108 * <p> 109 * @return The <code>SQLException</code> the driver is about to throw 110 * <p> 111 * @since 1.6 112 */ 113 public SQLException getSQLException() { 114 115 return this.exception; 116 } 117 } 118