1. /*
  2. * @(#)ResultSetMetaData.java 1.16 01/11/29
  3. *
  4. * Copyright 2002 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 find out about the types
  10. * and properties of the columns in a ResultSet.
  11. */
  12. public interface ResultSetMetaData {
  13. /**
  14. * Returns the number of columns in this ResultSet.
  15. *
  16. * @return the number of columns
  17. * @exception SQLException if a database access error occurs
  18. */
  19. int getColumnCount() throws SQLException;
  20. /**
  21. * Indicates whether the column is automatically numbered, thus read-only.
  22. *
  23. * @param column the first column is 1, the second is 2, ...
  24. * @return true if so
  25. * @exception SQLException if a database access error occurs
  26. */
  27. boolean isAutoIncrement(int column) throws SQLException;
  28. /**
  29. * Indicates whether a column's case matters.
  30. *
  31. * @param column the first column is 1, the second is 2, ...
  32. * @return true if so
  33. * @exception SQLException if a database access error occurs
  34. */
  35. boolean isCaseSensitive(int column) throws SQLException;
  36. /**
  37. * Indicates whether the column can be used in a where clause.
  38. *
  39. * @param column the first column is 1, the second is 2, ...
  40. * @return true if so
  41. * @exception SQLException if a database access error occurs
  42. */
  43. boolean isSearchable(int column) throws SQLException;
  44. /**
  45. * Indicates whether the column is a cash value.
  46. *
  47. * @param column the first column is 1, the second is 2, ...
  48. * @return true if so
  49. * @exception SQLException if a database access error occurs
  50. */
  51. boolean isCurrency(int column) throws SQLException;
  52. /**
  53. * Indicates the nullability of values in the designated column.
  54. *
  55. * @param column the first column is 1, the second is 2, ...
  56. * @return the nullability status of the given column; one of columnNoNulls,
  57. * columnNullable or columnNullableUnknown
  58. * @exception SQLException if a database access error occurs
  59. */
  60. int isNullable(int column) throws SQLException;
  61. /**
  62. * Column does not allow NULL values.
  63. */
  64. int columnNoNulls = 0;
  65. /**
  66. * Column allows NULL values.
  67. */
  68. int columnNullable = 1;
  69. /**
  70. * Nullability of column values is unknown.
  71. */
  72. int columnNullableUnknown = 2;
  73. /**
  74. * Indicates whether values in the column are signed numbers.
  75. *
  76. * @param column the first column is 1, the second is 2, ...
  77. * @return true if so
  78. * @exception SQLException if a database access error occurs
  79. */
  80. boolean isSigned(int column) throws SQLException;
  81. /**
  82. * Indicates the column's normal max width in chars.
  83. *
  84. * @param column the first column is 1, the second is 2, ...
  85. * @return the normal maximum number of characters allowed as the width
  86. * of the designated column
  87. * @exception SQLException if a database access error occurs
  88. */
  89. int getColumnDisplaySize(int column) throws SQLException;
  90. /**
  91. * Gets the suggested column title for use in printouts and
  92. * displays.
  93. *
  94. * @param column the first column is 1, the second is 2, ...
  95. * @return the suggested column title
  96. * @exception SQLException if a database access error occurs
  97. */
  98. String getColumnLabel(int column) throws SQLException;
  99. /**
  100. * Gets a column's name.
  101. *
  102. * @param column the first column is 1, the second is 2, ...
  103. * @return column name
  104. * @exception SQLException if a database access error occurs
  105. */
  106. String getColumnName(int column) throws SQLException;
  107. /**
  108. * Gets a column's table's schema.
  109. *
  110. * @param column the first column is 1, the second is 2, ...
  111. * @return schema name or "" if not applicable
  112. * @exception SQLException if a database access error occurs
  113. */
  114. String getSchemaName(int column) throws SQLException;
  115. /**
  116. * Gets a column's number of decimal digits.
  117. *
  118. * @param column the first column is 1, the second is 2, ...
  119. * @return precision
  120. * @exception SQLException if a database access error occurs
  121. */
  122. int getPrecision(int column) throws SQLException;
  123. /**
  124. * Gets a column's number of digits to right of the decimal point.
  125. *
  126. * @param column the first column is 1, the second is 2, ...
  127. * @return scale
  128. * @exception SQLException if a database access error occurs
  129. */
  130. int getScale(int column) throws SQLException;
  131. /**
  132. * Gets a column's table name.
  133. *
  134. * @param column the first column is 1, the second is 2, ...
  135. * @return table name or "" if not applicable
  136. * @exception SQLException if a database access error occurs
  137. */
  138. String getTableName(int column) throws SQLException;
  139. /**
  140. * Gets a column's table's catalog name.
  141. *
  142. * @param column the first column is 1, the second is 2, ...
  143. * @return column name or "" if not applicable.
  144. * @exception SQLException if a database access error occurs
  145. */
  146. String getCatalogName(int column) throws SQLException;
  147. /**
  148. * Retrieves a column's SQL type.
  149. *
  150. * @param column the first column is 1, the second is 2, ...
  151. * @return SQL type from java.sql.Types
  152. * @exception SQLException if a database access error occurs
  153. * @see Types
  154. */
  155. int getColumnType(int column) throws SQLException;
  156. /**
  157. * Retrieves a column's database-specific type name.
  158. *
  159. * @param column the first column is 1, the second is 2, ...
  160. * @return type name used by the database. If the column type is
  161. * a user-defined type, then a fully-qualified type name is returned.
  162. * @exception SQLException if a database access error occurs
  163. */
  164. String getColumnTypeName(int column) throws SQLException;
  165. /**
  166. * Indicates whether a column is definitely not writable.
  167. *
  168. * @param column the first column is 1, the second is 2, ...
  169. * @return true if so
  170. * @exception SQLException if a database access error occurs
  171. */
  172. boolean isReadOnly(int column) throws SQLException;
  173. /**
  174. * Indicates whether it is possible for a write on the column to succeed.
  175. *
  176. * @param column the first column is 1, the second is 2, ...
  177. * @return true if so
  178. * @exception SQLException if a database access error occurs
  179. */
  180. boolean isWritable(int column) throws SQLException;
  181. /**
  182. * Indicates whether a write on the column will definitely succeed.
  183. *
  184. * @param column the first column is 1, the second is 2, ...
  185. * @return true if so
  186. * @exception SQLException if a database access error occurs
  187. */
  188. boolean isDefinitelyWritable(int column) throws SQLException;
  189. //--------------------------JDBC 2.0-----------------------------------
  190. /**
  191. * JDBC 2.0
  192. *
  193. * <p>Returns the fully-qualified name of the Java class whose instances
  194. * are manufactured if the method <code>ResultSet.getObject</code>
  195. * is called to retrieve a value
  196. * from the column. <code>ResultSet.getObject</code> may return a subclass of the
  197. * class returned by this method.
  198. *
  199. * @return the fully-qualified name of the class in the Java programming
  200. * language that would be used by the method
  201. * <code>ResultSet.getObject</code> to retrieve the value in the specified
  202. * column. This is the class name used for custom mapping.
  203. * @exception SQLException if a database access error occurs
  204. */
  205. String getColumnClassName(int column) throws SQLException;
  206. }