Path: blob/master/src/java.sql/share/classes/javax/sql/StatementEvent.java
41152 views
/*1* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425/*26* Created on Apr 28, 200527*/28package javax.sql;2930import java.sql.PreparedStatement;31import java.sql.SQLException;32import java.util.EventObject;3334/**35* A {@code StatementEvent} is sent to all {@code StatementEventListener}s which were36* registered with a {@code PooledConnection}. This occurs when the driver determines that a37* {@code PreparedStatement} that is associated with the {@code PooledConnection} has been closed or the driver determines38* is invalid.39*40* @since 1.641*/42public class StatementEvent extends EventObject {4344static final long serialVersionUID = -8089573731826608315L;45/**46* The {@code SQLException} the driver is about to throw to the application.47*/48private SQLException exception;4950/**51* The {@code PreparedStatement} that is being closed or is invalid.52*/53@SuppressWarnings("serial") // Not statically typed as Serializable54private PreparedStatement statement;5556/**57* Constructs a {@code StatementEvent} with the specified {@code PooledConnection} and58* {@code PreparedStatement}. The {@code SQLException} contained in the event defaults to59* null.60*61* @param con The {@code PooledConnection} that the closed or invalid62* {@code PreparedStatement}is associated with.63* @param statement The {@code PreparedStatement} that is being closed or is invalid64*65* @throws IllegalArgumentException if {@code con} is null.66*67* @since 1.668*/69public StatementEvent(PooledConnection con,70PreparedStatement statement) {7172super(con);7374this.statement = statement;75this.exception = null;76}7778/**79* Constructs a {@code StatementEvent} with the specified {@code PooledConnection},80* {@code PreparedStatement} and {@code SQLException}81*82* @param con The {@code PooledConnection} that the closed or invalid {@code PreparedStatement}83* is associated with.84* @param statement The {@code PreparedStatement} that is being closed or is invalid85* @param exception The {@code SQLException }the driver is about to throw to86* the application87*88* @throws IllegalArgumentException if {@code con} is null.89*90* @since 1.691*/92public StatementEvent(PooledConnection con,93PreparedStatement statement,94SQLException exception) {9596super(con);9798this.statement = statement;99this.exception = exception;100}101102/**103* Returns the {@code PreparedStatement} that is being closed or is invalid104*105* @return The {@code PreparedStatement} that is being closed or is invalid106*107* @since 1.6108*/109public PreparedStatement getStatement() {110111return this.statement;112}113114/**115* Returns the {@code SQLException} the driver is about to throw116*117* @return The {@code SQLException} the driver is about to throw118*119* @since 1.6120*/121public SQLException getSQLException() {122123return this.exception;124}125}126127128