1. /*
  2. * @(#)RowSetWarning.java 1.5 04/03/11
  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.rowset;
  8. import java.sql.SQLException;
  9. /**
  10. * An extension of <code>SQLException</code> that provides information
  11. * about database warnings set on <code>RowSet</code> objects.
  12. * Warnings are silently chained to the object whose method call
  13. * caused it to be reported.
  14. * This class complements the <code>SQLWarning</code> class.
  15. * <P>
  16. * Rowset warnings may be retrieved from <code>JdbcRowSet</code>,
  17. * <code>CachedRowSet</code><sup><font size=-2>TM</font></sup>,
  18. * <code>WebRowSet</code>, <code>FilteredRowSet</code>, or <code>JoinRowSet</code>
  19. * implementations. To retrieve the first warning reported on any
  20. * <code>RowSet</code>
  21. * implementation, use the method <code>getRowSetWarnings</code> defined
  22. * in the <code>JdbcRowSet</code> interface or the <code>CachedRowSet</code>
  23. * interface. To retrieve a warning chained to the first warning, use the
  24. * <code>RowSetWarning</code> method
  25. * <code>getNextWarning</code>. To retrieve subsequent warnings, call
  26. * <code>getNextWarning</code> on each <code>RowSetWarning</code> object that is
  27. * returned.
  28. * <P>
  29. * The inherited methods <code>getMessage</code>, <code>getSQLState</code>,
  30. * and <code>getErrorCode</code> retrieve information contained in a
  31. * <code>RowSetWarning</code> object.
  32. */
  33. public class RowSetWarning extends SQLException {
  34. /**
  35. * RowSetWarning object handle.
  36. */
  37. private RowSetWarning rwarning;
  38. /**
  39. * Constructs a <code>RowSetWarning</code> object
  40. * with the given value for the reason; SQLState defaults to null,
  41. * and vendorCode defaults to 0.
  42. *
  43. * @param reason a <code>String</code> object giving a description
  44. * of the warning; if the <code>String</code> is <code>null</code>,
  45. * this constructor behaves like the default (zero parameter)
  46. * <code>RowSetWarning</code> constructor
  47. */
  48. public RowSetWarning(String reason) {
  49. super(reason);
  50. }
  51. /**
  52. * Constructs a default <code>RowSetWarning</code> object. The reason
  53. * defaults to <code>null</code>, SQLState defaults to null and vendorCode
  54. * defaults to 0.
  55. */
  56. public RowSetWarning() {
  57. super();
  58. }
  59. /**
  60. * Constructs a <code>RowSetWarning</code> object initialized with the
  61. * given values for the reason and SQLState. The vendor code defaults to 0.
  62. *
  63. * If the <code>reason</code> or <code>SQLState</code> parameters are <code>null</code>,
  64. * this constructor behaves like the default (zero parameter)
  65. * <code>RowSetWarning</code> constructor.
  66. *
  67. * @param reason a <code>String</code> giving a description of the
  68. * warning;
  69. * @param SQLState an XOPEN code identifying the warning; if a non standard
  70. * XOPEN <i>SQLState</i> is supplied, no exception is thrown.
  71. */
  72. public RowSetWarning(java.lang.String reason, java.lang.String SQLState) {
  73. super(reason, SQLState);
  74. }
  75. /**
  76. * Constructs a fully specified <code>RowSetWarning</code> object initialized
  77. * with the given values for the reason, SQLState and vendorCode.
  78. *
  79. * If the <code>reason</code>, or the <code>SQLState</code>
  80. * parameters are <code>null</code>, this constructor behaves like the default
  81. * (zero parameter) <code>RowSetWarning</code> constructor.
  82. *
  83. * @param reason a <code>String</code> giving a description of the
  84. * warning;
  85. * @param SQLState an XOPEN code identifying the warning; if a non standard
  86. * XPOEN <i>SQLState</i> is supplied, no exception is thrown.
  87. * @param vendorCode a database vendor-specific warning code
  88. */
  89. public RowSetWarning(java.lang.String reason, java.lang.String SQLState, int vendorCode) {
  90. super(reason, SQLState, vendorCode);
  91. }
  92. /**
  93. * Retrieves the warning chained to this <code>RowSetWarning</code>
  94. * object.
  95. *
  96. * @return the <code>RowSetWarning</code> object chained to this one; if no
  97. * <code>RowSetWarning</code> object is chained to this one,
  98. * <code>null</code> is returned (default value)
  99. * @see #setNextWarning
  100. */
  101. public RowSetWarning getNextWarning() {
  102. return rwarning;
  103. }
  104. /**
  105. * Sets <i>warning</i> as the next warning, that is, the warning chained
  106. * to this <code>RowSetWarning</code> object.
  107. *
  108. * @param warning the <code>RowSetWarning</code> object to be set as the
  109. * next warning; if the <code>RowSetWarning</code> is null, this
  110. * represents the finish point in the warning chain
  111. * @see #getNextWarning
  112. */
  113. public void setNextWarning(RowSetWarning warning) {
  114. rwarning = warning;
  115. }
  116. static final long serialVersionUID = 6678332766434564774L;
  117. }