1.51.2

interbase.interclient
Class Array

java.lang.Object
  |
  +--interbase.interclient.Array

public final class Array
extends Object
implements Array

The Java mapping for an SQL Array. By default, an Array is a transaction duration reference to an SQL array. By default, an Array is implemented using an SQL LOCATOR(array) internally.

InterClient Notes:
JDBC 2.0 array support is based on the SQL3 standard and does not require support for multidimensional arrays (or array of arrays). InterClient supports the array data type as specified by the JDBC 2 specification, but in addition to this support InterClient provides for multi-dimensional arrays as supported by InterBase. InterBase, supports multi-dimensional arrays up to 16 dimensions. Because of these differences InterClient provides extension methods to allow a users to work with multi-dimensional arrays.

In accordance with the JDBC 2 specification, Array instances are created using ResultSet.getArray. So, in accordance with JDBC 2, there is no public constructor for this class.

An InterBase array may be referenced by an Array instance for the duration of the transaction in which it was created. Although it is not good programming practice, an Array could be used even after its transaction has finished, but its associated InterBase array may be garbage collected without warning at any point in time after its transaction completes. So, you may still be able get a Java array within the transaction context of the completed transaction that created it, even after the InterBase array has been modified by another transaction, but you will get an error from the engine if the InterBase array has been garbage collected.

Note: Because of a current InterBase limitation only the "8859_1" character encoding is supported for arrays of Strings.

For further information on InterClient's support of InterBase arrays see InterClient Array Support in the InterClient help directory.

Since:
JDBC 2, proposed for InterClient 2.0

Method Summary
 Object getArray()
          Retrieve the contents of this SQL array as a Java Array object.
 Object getArray(int[][] sliceBounds)
          Gets a sub-array described by sliceBounds of this SQL array.
 Object getArray(long index, int count)
          Gets a Java array object containing a slice of this SQL array.
 Object getArray(long index, int count, Map map)
          Gets a Java array object containing a slice of this SQL array using a type-map customization.
 Object getArray(Map map)
          Retrieve the contents of this SQL array as a Java array object using map for type-map customization.
 int getBaseType()
          Returns the JDBC type of the elements in this array.
 String getBaseTypeName()
          Returns the SQL type name of the elements in this array.
 ResultSet getResultSet()
          Gets a result set that contains the elements of this array.
 ResultSet getResultSet(int[][] sliceBounds)
          Gets a result set holding the elements of a sub-array, or slice, described by sliceBounds.
 ResultSet getResultSet(long index, int count)
          Gets a result set holding the elements of the subarray that starts at index index and contains up to count successive elements.
 ResultSet getResultSet(long index, int count, Map map)
          Returns a result set holding the elements of the subarray that starts at index index and contains up to count successive elements.
 ResultSet getResultSet(Map map)
          Gets a result set that contains the elements of this array using map to map the array elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getBaseTypeName

public String getBaseTypeName()
                       throws SQLException
Returns the SQL type name of the elements in this array. If the elements are a built-in type, it returns the database-specific type name of the elements. If the elements are a user-defined type (UDT), this method returns the fully-qualified SQL type name.
Specified by:
getBaseTypeName in interface Array
Returns:
the database-specific name for a built-in base type or the fully-qualified SQL type name for a base type that is a UDT
Throws:
SQLException - if an error occurs while attempting to access the type name
Since:
JDBC 2, proposed for InterClient 2.0

getBaseType

public int getBaseType()
                throws SQLException
Returns the JDBC type of the elements in this array.
Specified by:
getBaseType in interface Array
Returns:
a constant from the class java.sql.Types that is the type code for the elements in this array.
Throws:
SQLException - if an error occurs while attempting to access the the base type
Since:
JDBC 2, proposed for InterClient 2.0

getArray

public Object getArray()
                throws SQLException
Retrieve the contents of this SQL array as a Java Array object. This version of the method getArray uses the type map associated with the connection for customizations of the type mappings.

Conceptually, this method calls getObject() on each element of the array and returns a Java array containing the result. Except when the array element type maps to a Java primitive type, such as int, boolean, etc. In this case, an array of primitive type values, i.e. an array of int, is returned, not an array of Integer. This exception for primitive types should improve performance as well as usability.

Specified by:
getArray in interface Array
Returns:
a Java array containing the ordered elements of the SQL array designated by this object.
Throws:
SQLException - if an error occurs while attempting to access the array
Since:
JDBC 2, proposed for InterClient 2.0

getArray

public Object getArray(Map map)
                throws SQLException
Retrieve the contents of this SQL array as a Java array object using map for type-map customization. If the base type of the array does not match a user-defined type in map, the standard mapping is used instead.

Conceptually, this method calls getObject() on each element of the array and returns a Java array containing the result. Except when the array element type maps to a Java primitive type, such as int, boolean, etc. In this case, an array of primitive type values, i.e. an array of int, is returned, not an array of Integer. This exception for primitive types should improve performance as well as usability.

Specified by:
getArray in interface Array
Parameters:
map - a java.util.Map object that contains mappings of SQL type names to classes in the Java programming language
Returns:
an array in the Java programming language that contains the ordered elements of the SQL array designated by this object
Throws:
SQLException - if an error occurs while attempting to access the array
Since:
JDBC 2, not yet supported

getArray

public Object getArray(long index,
                       int count)
                throws SQLException
Gets a Java array object containing a slice of this SQL array. The array slice begins at the given index and contains up to count successive elements of the SQL array. This method uses the type-map associated with the connection for customizations of the type-mappings.
Specified by:
getArray in interface Array
Parameters:
index - the array index of the first element to retrieve; the first element is at index 1
count - the number of successive SQL array elements to retrieve
Returns:
an array containing up to count consecutive elements of the SQL array, beginning with element index
Throws:
SQLException - if an error occurs while attempting to access the array
Since:
JDBC 2, proposed for InterClient 2.0

getArray

public Object getArray(long index,
                       int count,
                       Map map)
                throws SQLException
Gets a Java array object containing a slice of this SQL array using a type-map customization. The array slice begins at the given index and contains up to count successive elements of the SQL array. This method uses the specified map for type-map customizations unless the base type of the array does not match a user- defined type in map, in which case it uses the standard mapping.
Specified by:
getArray in interface Array
Parameters:
index - the array index of the first element to retrieve; the first element is at index 1
count - the number of successive SQL array elements to retrieve
map - a java.util.Map object that contains SQL type names and the classes in the Java programming language to which they are mapped
Returns:
an array containing up to count consecutive elements of the SQL array designated by this Array object, beginning with element index.
Throws:
SQLException - if an error occurs while attempting to access the array
Since:
JDBC 2, not yet supported

getResultSet

public ResultSet getResultSet()
                       throws SQLException
Gets a result set that contains the elements of this array. If appropriate, the elements of the array are mapped using the connection's type map; otherwise, the standard mapping is used.

The result set contains one row for each array element, with two columns in each row. The second column stores the element value; the first column stores the index into the array for that element (with the first array element being at index 1). The rows are in ascending order corresponding to the order of the indices.

Specified by:
getResultSet in interface Array
Returns:
a ResultSet object containing one row for each of the elements in the array designated by this Array object, with the rows in ascending order based on the indices.
Throws:
SQLException - if an error occurs while attempting to access the array
Since:
JDBC 2, proposed for future release, not yet supported

getResultSet

public ResultSet getResultSet(Map map)
                       throws SQLException
Gets a result set that contains the elements of this array using map to map the array elements. If the base type of the array does not match a user-defined type in map, the standard mapping is used instead.

The result set contains one row for each array element, with two columns in each row. The second column stores the element value; the first column stores the index into the array for that element (with the first array element being at index 1). The rows are in ascending order corresponding to the order of the indices.

Specified by:
getResultSet in interface Array
Parameters:
map - contains mapping of SQL user-defined types to classes in the Java(tm) programming language
Returns:
a ResultSet object containing one row for each of the elements in the array designated by this Array object, with the rows in ascending order based on the indices.
Throws:
SQLException - if an error occurs while attempting to access the array
Since:
JDBC 2, not yet supported

getResultSet

public ResultSet getResultSet(long index,
                              int count)
                       throws SQLException
Gets a result set holding the elements of the subarray that starts at index index and contains up to count successive elements. This method uses the connection's type map to map the elements of the array if the map contains an entry for the base type. Otherwise, the standard mapping is used.

The result set has one row for each element of the SQL array designated by this object, with the first row containing the element at index index. The result set has up to count rows in ascending order based on the indices. Each row has two columns: The second column stores the element value; the first column stroes the index into the array for that element.

Specified by:
getResultSet in interface Array
Parameters:
index - the array index of the first element to retrieve; the first element is at index 1
count - the number of successive SQL array elements to retrieve
Returns:
a ResultSet object containing up to count consecutive elements of the SQL array designated by this Array object, starting at index index.
Throws:
SQLException - if an error occurs while attempting to access the array
Since:
JDBC 2, proposed for future release, not yet supported

getResultSet

public ResultSet getResultSet(long index,
                              int count,
                              Map map)
                       throws SQLException
Returns a result set holding the elements of the subarray that starts at index index and contains up to count successive elements. This method uses the Map object map to map the elements of the array unless the base type of the array does not match a user-defined type in map, in which case it uses the standard mapping.

The result set has one row for each element of the SQL array designated by this object, with the first row containing the element at index index. The result set has up to count rows in ascending order based on the indices. Each row has two columns: The second column stores the element value; the first column stroes the index into the array for that element.

Specified by:
getResultSet in interface Array
Parameters:
index - the array index of the first element to retrieve; the first element is at index 1
count - the number of successive SQL array elements to retrieve
map - the Map object that contains the mapping of SQL type names to classes in the Java(tm) programming language
Returns:
a ResultSet object containing up to count consecutive elements of the SQL array designated by this Array object, starting at index index.
Throws:
SQLException - if an error occurs while attempting to access the array
Since:
JDBC 2, not yet supported

getArray

public Object getArray(int[][] sliceBounds)
                throws SQLException
Gets a sub-array described by sliceBounds of this SQL array. The slice is specified by a two-dimensional array sliceBounds. The number of rows in this array must be equal to the number of SQL array dimensions and the number of columns is always two - lower and upper bounds for each dimension. For example, an array defined in InterBase as INTEGER[2:5][3:10][100:200] is described by the following array of pairs:
 sliceBounds[0] = {2, 5}
 sliceBounds[1] = {3, 10}
 sliceBounds[2] = {100, 200}
 
Returns:
an array described by sliceBounds
Throws:
SQLException - if an error occurs while attempting to access the array
Since:
Extension, proposed for InterClient 2.0

getResultSet

public ResultSet getResultSet(int[][] sliceBounds)
                       throws SQLException
Gets a result set holding the elements of a sub-array, or slice, described by sliceBounds. The slice is specified by a two-dimensional array sliceBounds. The number of rows in this array must be equal to the number of SQL array dimensions and the number of columns is always two - lower and upper bounds for each dimension. For example, an array defined in InterBase as INTEGER[2:5][3:10][100:200] is described by the following array of pairs:
 sliceBounds[0] = {2, 5}
 sliceBounds[1] = {3, 10}
 sliceBounds[2] = {100, 200}
 
Returns:
a result set for a subarray described by sliceBounds
Throws:
SQLException - if an error occurs while attempting to access the array
Since:
Extension, proposed for future release, not yet supported

1.51.2

Send comments or suggestions to interclient@interbase.com