1. /*
  2. * @(#)ParameterMetaData.java 1.11 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 java.sql;
  8. /**
  9. * An object that can be used to get information about the types
  10. * and properties of the parameters in a <code>PreparedStatement</code> object.
  11. *
  12. * @since 1.4
  13. */
  14. public interface ParameterMetaData {
  15. /**
  16. * Retrieves the number of parameters in the <code>PreparedStatement</code>
  17. * object for which this <code>ParameterMetaData</code> object contains
  18. * information.
  19. *
  20. * @return the number of parameters
  21. * @exception SQLException if a database access error occurs
  22. * @since 1.4
  23. */
  24. int getParameterCount() throws SQLException;
  25. /**
  26. * Retrieves whether null values are allowed in the designated parameter.
  27. *
  28. * @param param the first parameter is 1, the second is 2, ...
  29. * @return the nullability status of the given parameter; one of
  30. * <code>ParameterMetaData.parameterNoNulls</code>,
  31. * <code>ParameterMetaData.parameterNullable</code>, or
  32. * <code>ParameterMetaData.parameterNullableUnknown</code>
  33. * @exception SQLException if a database access error occurs
  34. * @since 1.4
  35. */
  36. int isNullable(int param) throws SQLException;
  37. /**
  38. * The constant indicating that a
  39. * parameter will not allow <code>NULL</code> values.
  40. */
  41. int parameterNoNulls = 0;
  42. /**
  43. * The constant indicating that a
  44. * parameter will allow <code>NULL</code> values.
  45. */
  46. int parameterNullable = 1;
  47. /**
  48. * The constant indicating that the
  49. * nullability of a parameter is unknown.
  50. */
  51. int parameterNullableUnknown = 2;
  52. /**
  53. * Retrieves whether values for the designated parameter can be signed numbers.
  54. *
  55. * @param param the first parameter is 1, the second is 2, ...
  56. * @return <code>true</code> if so; <code>false</code> otherwise
  57. * @exception SQLException if a database access error occurs
  58. * @since 1.4
  59. */
  60. boolean isSigned(int param) throws SQLException;
  61. /**
  62. * Retrieves the designated parameter's number of decimal digits.
  63. *
  64. * @param param the first parameter is 1, the second is 2, ...
  65. * @return precision
  66. * @exception SQLException if a database access error occurs
  67. * @since 1.4
  68. */
  69. int getPrecision(int param) throws SQLException;
  70. /**
  71. * Retrieves the designated parameter's number of digits to right of the decimal point.
  72. *
  73. * @param param the first parameter is 1, the second is 2, ...
  74. * @return scale
  75. * @exception SQLException if a database access error occurs
  76. * @since 1.4
  77. */
  78. int getScale(int param) throws SQLException;
  79. /**
  80. * Retrieves the designated parameter's SQL type.
  81. *
  82. * @param param the first parameter is 1, the second is 2, ...
  83. * @return SQL type from <code>java.sql.Types</code>
  84. * @exception SQLException if a database access error occurs
  85. * @since 1.4
  86. * @see Types
  87. */
  88. int getParameterType(int param) throws SQLException;
  89. /**
  90. * Retrieves the designated parameter's database-specific type name.
  91. *
  92. * @param param the first parameter is 1, the second is 2, ...
  93. * @return type the name used by the database. If the parameter type is
  94. * a user-defined type, then a fully-qualified type name is returned.
  95. * @exception SQLException if a database access error occurs
  96. * @since 1.4
  97. */
  98. String getParameterTypeName(int param) throws SQLException;
  99. /**
  100. * Retrieves the fully-qualified name of the Java class whose instances
  101. * should be passed to the method <code>PreparedStatement.setObject</code>.
  102. *
  103. * @param param the first parameter is 1, the second is 2, ...
  104. * @return the fully-qualified name of the class in the Java programming
  105. * language that would be used by the method
  106. * <code>PreparedStatement.setObject</code> to set the value
  107. * in the specified parameter. This is the class name used
  108. * for custom mapping.
  109. * @exception SQLException if a database access error occurs
  110. * @since 1.4
  111. */
  112. String getParameterClassName(int param) throws SQLException;
  113. /**
  114. * The constant indicating that the mode of the parameter is unknown.
  115. */
  116. int parameterModeUnknown = 0;
  117. /**
  118. * The constant indicating that the parameter's mode is IN.
  119. */
  120. int parameterModeIn = 1;
  121. /**
  122. * The constant indicating that the parameter's mode is INOUT.
  123. */
  124. int parameterModeInOut = 2;
  125. /**
  126. * The constant indicating that the parameter's mode is OUT.
  127. */
  128. int parameterModeOut = 4;
  129. /**
  130. * Retrieves the designated parameter's mode.
  131. *
  132. * @param param the first parameter is 1, the second is 2, ...
  133. * @return mode of the parameter; one of
  134. * <code>ParameterMetaData.parameterModeIn</code>,
  135. * <code>ParameterMetaData.parameterModeOut</code>, or
  136. * <code>ParameterMetaData.parameterModeInOut</code>
  137. * <code>ParameterMetaData.parameterModeUnknown</code>.
  138. * @exception SQLException if a database access error occurs
  139. * @since 1.4
  140. */
  141. int getParameterMode(int param) throws SQLException;
  142. }