1. /*
  2. * @(#)ConnectionEvent.java 1.9 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.sql;
  8. import java.sql.SQLException;
  9. /**
  10. * <P>An <code>Event</code> object that provides information about the
  11. * source of a connection-related event. <code>ConnectionEvent</code>
  12. * objects are generated when an application closes a pooled connection
  13. * and when an error occurs. The <code>ConnectionEvent</code> object
  14. * contains two kinds of information:
  15. * <UL>
  16. * <LI>The pooled connection closed by the application
  17. * <LI>In the case of an error event, the <code>SQLException</code>
  18. * about to be thrown to the application
  19. * </UL>
  20. *
  21. * @since 1.4
  22. */
  23. public class ConnectionEvent extends java.util.EventObject {
  24. /**
  25. * <P>Constructs a <code>ConnectionEvent</code> object initialized with
  26. * the given <code>PooledConnection</code> object. <code>SQLException</code>
  27. * defaults to <code>null</code>.
  28. *
  29. * @param con the pooled connection that is the source of the event
  30. */
  31. public ConnectionEvent(PooledConnection con) {
  32. super(con);
  33. }
  34. /**
  35. * <P>Constructs a <code>ConnectionEvent</code> object initialized with
  36. * the given <code>PooledConnection</code> object and
  37. * <code>SQLException</code> object.
  38. *
  39. * @param con the pooled connection that is the source of the event
  40. * @param ex the SQLException about to be thrown to the application
  41. */
  42. public ConnectionEvent(PooledConnection con, SQLException ex) {
  43. super(con);
  44. this.ex = ex;
  45. }
  46. /**
  47. * <P>Retrieves the <code>SQLException</code> for this
  48. * <code>ConnectionEvent</code> object. May be <code>null</code>.
  49. *
  50. * @return the SQLException about to be thrown or <code>null</code>
  51. */
  52. public SQLException getSQLException() { return ex; }
  53. /**
  54. * The <code>SQLException</code> that the driver will throw to the
  55. * application when an error occurs and the pooled connection is no
  56. * longer usable.
  57. * @serial
  58. */
  59. private SQLException ex = null;
  60. /**
  61. * Private serial version unique ID to ensure serialization
  62. * compatibility.
  63. */
  64. static final long serialVersionUID = -4843217645290030002L;
  65. }