1. /*
  2. * @(#)Array.java 1.11 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. * JDBC 2.0
  10. *
  11. * <p>
  12. * The mapping in the Java programming language for the SQL type
  13. * <code>ARRAY</code>.
  14. * By default, an <code>Array</code> is a transaction duration
  15. * reference to an SQL array. By default, an <code>Array</code>
  16. * is implemented using an SQL LOCATOR(array) internally.
  17. */
  18. public interface Array {
  19. /**
  20. * Returns the SQL type name of the elements in
  21. * the array designated by this <code>Array</code> object.
  22. * If the elements are a built-in type, it returns
  23. * the database-specific type name of the elements.
  24. * If the elements are a user-defined type (UDT),
  25. * this method returns the fully-qualified SQL type name.
  26. * @return a <code>String</code> that is the database-specific
  27. * name for a built-in base type or the fully-qualified SQL type
  28. * name for a base type that is a UDT
  29. * @exception SQLException if an error occurs while attempting
  30. * to access the type name
  31. */
  32. String getBaseTypeName() throws SQLException;
  33. /**
  34. * Returns the JDBC type of the elements in the array designated
  35. * by this <code>Array</code> object.
  36. * @return a constant from the class {@link java.sql.Types} that is
  37. * the type code for the elements in the array designated by this
  38. * <code>Array</code> object.
  39. * @exception SQLException if an error occurs while attempting
  40. * to access the base type
  41. */
  42. int getBaseType() throws SQLException;
  43. /**
  44. * Retrieves the contents of the SQL array designated by this
  45. * <code>Array</code> object in the form of an array in the Java
  46. * programming language. This version of the method <code>getArray</code>
  47. * uses the type map associated with the connection for customizations of
  48. * the type mappings.
  49. * @return an array in the Java programming language that contains
  50. * the ordered elements of the SQL ARRAY object designated by this object
  51. * @exception SQLException if an error occurs while attempting to
  52. * access the array
  53. */
  54. Object getArray() throws SQLException;
  55. /**
  56. * Retrieves the contents of the SQL array designated by this
  57. * <code>Array</code>
  58. * object, using the specified <code>map</code> for type map
  59. * customizations. If the base type of the array does not
  60. * match a user-defined type in <code>map</code>, the standard
  61. * mapping is used instead.
  62. * @param map a <code>java.util.Map</code> object that contains mappings
  63. * of SQL type names to classes in the Java programming language
  64. * @return an array in the Java programming language that contains the ordered
  65. * elements of the SQL array designated by this object
  66. * @exception SQLException if an error occurs while attempting to
  67. * access the array
  68. */
  69. Object getArray(java.util.Map map) throws SQLException;
  70. /**
  71. * Returns an array containing a slice of the SQL array, beginning with the
  72. * specified <code>index</code> and containing up to <code>count</code>
  73. * successive elements of the SQL array. This method uses the type-map
  74. * associated with the connection for customizations of the type-mappings.
  75. * @param index the array index of the first element to retrieve;
  76. * the first element is at index 1
  77. * @param count the number of successive SQL array elements to retrieve
  78. * @return an array containing up to <code>count</code> consecutive elements
  79. * of the SQL array, beginning with element <code>index</code>
  80. * @exception SQLException if an error occurs while attempting to
  81. * access the array
  82. */
  83. Object getArray(long index, int count) throws SQLException;
  84. /**
  85. * Returns an array containing a slice of the SQL array object
  86. * designated by this object, beginning with the specified
  87. * <code>index</code> and containing up to <code>count</code>
  88. * successive elements of the SQL array. This method uses
  89. * the specified <code>map</code> for type-map customizations
  90. * unless the base type of the array does not match a user-
  91. * defined type in <code>map</code>, in which case it
  92. * uses the standard mapping.
  93. * @param index the array index of the first element to retrieve;
  94. * the first element is at index 1
  95. * @param count the number of successive SQL array elements to
  96. * retrieve
  97. * @param map a <code>java.util.Map</code> object
  98. * that contains SQL type names and the classes in
  99. * the Java programming language to which they are mapped
  100. * @return an array containing up to <code>count</code>
  101. * consecutive elements of the SQL array designated by this
  102. * <code>Array</code> object, beginning with element
  103. * <code>index</code>.
  104. * @exception SQLException if an error occurs while attempting to
  105. * access the array
  106. */
  107. Object getArray(long index, int count, java.util.Map map)
  108. throws SQLException;
  109. /**
  110. * Returns a result set that contains the elements of the array
  111. * designated by this <code>Array</code> object. If appropriate,
  112. * the elements of the array are mapped using the connection's type
  113. * map; otherwise, the standard mapping is used.
  114. * <p>
  115. * The result set contains one row for each array element, with
  116. * two columns in each row. The second column stores the element
  117. * value; the first column stores the index into the array for
  118. * that element (with the first array element being at index 1).
  119. * The rows are in ascending order corresponding to
  120. * the order of the indices.
  121. * @return a {@link ResultSet} object containing one row for each
  122. * of the elements in the array designated by this <code>Array</code>
  123. * object, with the rows in ascending order based on the indices.
  124. * @exception SQLException if an error occurs while attempting to
  125. * access the array
  126. */
  127. ResultSet getResultSet () throws SQLException;
  128. /**
  129. * Returns a result set that contains the elements of the array
  130. * designated by this <code>Array</code> object and uses the given
  131. * <code>map</code> to map the array elements. If the base
  132. * type of the array does not match a user-defined type in
  133. * <code>map</code>, the standard mapping is used instead.
  134. * <p>
  135. * The result set contains one row for each array element, with
  136. * two columns in each row. The second column stores the element
  137. * value; the first column stores the index into the array for
  138. * that element (with the first array element being at index 1).
  139. * The rows are in ascending order corresponding to
  140. * the order of the indices.
  141. * @param map contains mapping of SQL user-defined types to
  142. * classes in the Java(tm) programming language
  143. * @return a <code>ResultSet</code> object containing one row for each
  144. * of the elements in the array designated by this <code>Array</code>
  145. * object, with the rows in ascending order based on the indices.
  146. * @exception SQLException if an error occurs while attempting to
  147. * access the array
  148. */
  149. ResultSet getResultSet (java.util.Map map) throws SQLException;
  150. /**
  151. * Returns a result set holding the elements of the subarray that
  152. * starts at index <code>index</code> and contains up to
  153. * <code>count</code> successive elements. This method uses
  154. * the connection's type map to map the elements of the array if
  155. * the map contains an entry for the base type. Otherwise, the
  156. * standard mapping is used.
  157. * <P>
  158. * The result set has one row for each element of the SQL array
  159. * designated by this object, with the first row containing the
  160. * element at index <code>index</code>. The result set has
  161. * up to <code>count</code> rows in ascending order based on the
  162. * indices. Each row has two columns: The second column stores
  163. * the element value; the first column stroes the index into the
  164. * array for that element.
  165. * @param index the array index of the first element to retrieve;
  166. * the first element is at index 1
  167. * @param count the number of successive SQL array elements to retrieve
  168. * @return a <code>ResultSet</code> object containing up to
  169. * <code>count</code> consecutive elements of the SQL array
  170. * designated by this <code>Array</code> object, starting at
  171. * index <code>index</code>.
  172. * @exception SQLException if an error occurs while attempting to
  173. * access the array
  174. */
  175. ResultSet getResultSet(long index, int count) throws SQLException;
  176. /**
  177. * Returns a result set holding the elements of the subarray that
  178. * starts at index <code>index</code> and contains up to
  179. * <code>count</code> successive elements. This method uses
  180. * the <code>Map</code> object <code>map</code> to map the elements
  181. * of the array unless the base type of the array does not match
  182. * a user-defined type in <code>map</code>, in which case it uses
  183. * the standard mapping.
  184. * <P>
  185. * The result set has one row for each element of the SQL array
  186. * designated by this object, with the first row containing the
  187. * element at index <code>index</code>. The result set has
  188. * up to <code>count</code> rows in ascending order based on the
  189. * indices. Each row has two columns: The second column stores
  190. * the element value; the first column stroes the index into the
  191. * array for that element.
  192. * @param index the array index of the first element to retrieve;
  193. * the first element is at index 1
  194. * @param count the number of successive SQL array elements to retrieve
  195. * @param map the <code>Map</code> object that contains the mapping
  196. * of SQL type names to classes in the Java(tm) programming language
  197. * @return a <code>ResultSet</code> object containing up to
  198. * <code>count</code> consecutive elements of the SQL array
  199. * designated by this <code>Array</code> object, starting at
  200. * index <code>index</code>.
  201. * @exception SQLException if an error occurs while attempting to
  202. * access the array
  203. *
  204. */
  205. ResultSet getResultSet (long index, int count, java.util.Map map)
  206. throws SQLException;
  207. }