KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > sql > StatementEvent


1 /*
2  * Created on Apr 28, 2005
3  */

4 package javax.sql;
5
6 import java.sql.PreparedStatement JavaDoc;
7 import java.sql.SQLException JavaDoc;
8 import java.util.EventObject JavaDoc;
9
10 /**
11  * A <code>StatementEvent</code> is sent to all <code>StatementEventListener</code>s which were
12  * registered with a <code>PooledConnection</code>. This occurs when the driver determines that a
13  * <code>PreparedStatement</code> that is associated with the <code>PooledConnection</code> has been closed or the driver determines
14  * is invalid.
15  * <p>
16  * @since 1.6
17  */

18 public class StatementEvent extends EventObject JavaDoc {
19     
20     private SQLException JavaDoc exception;
21     private PreparedStatement JavaDoc statement;
22     
23     /**
24      * Constructs a <code>StatementEvent</code> with the specified <code>PooledConnection</code> and
25      * <code>PreparedStatement</code>. The <code>SQLException</code> contained in the event defaults to
26      * null.
27      * <p>
28      * @param con The <code>PooledConnection</code> that the closed or invalid
29          * <code>PreparedStatement</code>is associated with.
30      * @param statement The <code>PreparedStatement</code> that is bieng closed or is invalid
31      * <p>
32          * @throws IllegalArgumentException if <code>con</code> is null.
33          *
34      * @since 1.6
35      */

36     public StatementEvent(PooledConnection JavaDoc con,
37                           PreparedStatement JavaDoc statement) {
38         
39         super(con);
40         
41         this.statement = statement;
42         this.exception = null;
43     }
44     
45     /**
46      * Constructs a <code>StatementEvent</code> with the specified <code>PooledConnection</code>,
47      * <code>PreparedStatement</code> and <code>SQLException</code>
48      * <p>
49      * @param con The <code>PooledConnection</code> that the closed or invalid <code>PreparedStatement</code>
50          * is associated with.
51      * @param statement The <code>PreparedStatement</code> that is being closed or is invalid
52      * @param exception The <code>SQLException </code>the driver is about to throw to
53      * the application
54          *
55          * @throws IllegalArgumentException if <code>con</code> is null.
56      * <p>
57      * @since 1.6
58      */

59     public StatementEvent(PooledConnection JavaDoc con,
60                           PreparedStatement JavaDoc statement,
61                           SQLException JavaDoc exception) {
62         
63         super(con);
64         
65         this.statement = statement;
66         this.exception = exception;
67     }
68     
69     /**
70      * Returns the <code>PreparedStatement</code> that is being closed or is invalid
71      * <p>
72      * @return The <code>PreparedStatement</code> that is being closed or is invalid
73      * <p>
74      * @since 1.6
75      */

76     public PreparedStatement JavaDoc getStatement() {
77         
78         return this.statement;
79     }
80
81     /**
82      * Returns the <code>SQLException</code> the driver is about to throw
83      * <p>
84      * @return The <code>SQLException</code> the driver is about to throw
85      * <p>
86      * @since 1.6
87      */

88     public SQLException JavaDoc getSQLException() {
89         
90         return this.exception;
91     }
92 }
93
Popular Tags