Nonstop Database, HiRDB Version 9 UAP Development Guide
![[Contents]](FIGURE/CONTENT.GIF)
![[Index]](FIGURE/INDEX.GIF)
![[Back]](FIGURE/FRONT.GIF)
18.4.10 Array interface
(1) Overview
The Array interface provides the following principal functions for accessing repetition columns:
- Acquisition of SQL Array values
- Acquisition of a result set containing SQL Array values
The JDBC driver uses the PrdbArray class to install the Array interface.
The JDBC driver generates PrdbArray class objects as return values of the getArray method of ResultSet.
(2) Methods
The table below lists the methods of the Array interface. The interface does not support methods that are not listed in the table. If an unsupported method is specified, the interface throws an SQLException.
Table 18-54 Array interface methods
Subsection |
Method |
Function |
(a) |
getArray() |
Acquires all elements of a repetition column as an Object array. |
(b) |
getArray(long index,int count) |
Retrieves some elements of a repetition column. |
(c) |
getBaseType() |
Acquires the JDBC type of the repetition column represented by the PrdbArray object as a java.sql.Types class literal. |
(d) |
getBaseTypeName() |
Acquires the data type name of the repetition column represented by the PrdbArray object. |
(e) |
getResultSet() |
Returns the ResultSet object containing the elements of a repetition column. |
(f) |
getResultSet(long index,int count) |
Returns the ResultSet object containing the elements of a repetition column. |
(a) getArray()
- Function
- Acquires all elements of a repetition column as an Object array.
- Format
public Object getArray() throws SQLException
- Arguments
- None.
- Return value
- All elements of a repetition column
- Functional detail
- This method acquires all elements of a repetition column as an Object array.
- The method returns the elements of the repetition column contained in the PrdbArray object in the Object array format. The following table shows the array that is returned depending on the data type:
HiRDB data type |
Array that is returned |
SMALLINT |
java.lang.Short[] |
INTEGR |
java.lang.Integer[] |
SMALLFLT,REAL |
java.lang.Float[] |
FLOAT,DOUBLE PRECISION |
java.sql.Double[] |
DECIMAL |
java.math.BigDecimal[] |
CHAR,NCHAR,MCHAR |
java.lagn.String[] |
VARCHAR,NVARCHAR,MVARCHAR |
java.lagn.String[] |
DATE |
java.sql.Date[] |
TIME |
java.sql.Time[] |
TIMESTAMP |
java.sql.Timestamp[] |
BINARY,BLOB |
java.io.InputStream[]# |
- #
- In actuality, no array is returned because HiRDB does not support BLOB or BINARY repetition columns and cannot create the corresponding PrdbArray object.
- Exceptions
- The JDBC driver throws an SQLException in the following cases:
- The PrdbResultSet object that created this PrdbArray object has been closed.
This includes the case where this driver has closed the PrdbResultSet object because the PrdbStatement object that created the PrdbResultSet object was closed.
- The Connection object used to create the PrdbStatement object, which created the PrdbResultSet object that created this PrdbArray object, is closed.
- CltResultSet#getXXX() resulted in an error.
(b) getArray(long index, int count)
- Function
- Retrieves some elements of a repetition column. This method acquires from a specified index as many elements as is specified as the maximum, and returns them as an Object array.
- Format
public Object getArray(long index, int count) throws SQLException
- Arguments
- long index
- Index of the first element to be retrieved (the first element is 1)
- int count
- Number of consecutive array elements to be acquired
- Return value
- An Object array containing as many elements as specified in count from the specified index
- Functional detail
- This method retrieves some elements of a repetition column. The method acquires from a specified index as many elements as is specified as the maximum, and returns them as an Object array.
- The following table shows the array that is returned depending on the relationship between the index and count argument values:
index |
count |
(index+count) |
Array that is returned |
0 < index number of elements |
0 count |
(index + count) - 1 number of elements |
Array whose length equals the count value |
(index + count) - 1 > number of elements |
Array whose length equals the number of elements - (index - 1) |
count < 0 |
-- |
SQLException is thrown |
index > number of elements |
-- |
-- |
SQLException is thrown |
index < 1 |
-- |
-- |
SQLException is thrown |
- Legend:
- --: Not applicable
- Exceptions
- The JDBC driver throws an SQLException in the following cases:
- The PrdbResultSet object that created this PrdbArray object has been closed.
This includes the case where this driver has closed the PrdbResultSet object because the PrdbStatement object that created the PrdbResultSet object was closed.
- The Connection object used to create the PrdbStatement object, which created the PrdbResultSet object that created this PrdbArray object, is closed.
- CltResultSet#getXXX() resulted in an error.
- The specified index argument value is less than 1 or the count argument value is less than 0.
- The specified index argument value is greater than the number of elements.
(c) getBaseType()
- Function
- Acquires the JDBC type of the repetition column represented by the PrdbArray object as a java.sql.Types class literal.
- Format
public int getBaseType() throws SQLException
- Arguments
- None.
- Return value
- java.sql.Types class literal indicating the JDBC type of the repetition column represented by the PrdbArray object
- Exceptions
- None.
(d) getBaseTypeName()
- Function
- Acquires the data type name of the repetition column represented by the PrdbArray object.
- Format
public String getBaseTypeName() throws SQLException
- Arguments
- None.
- Return value
- HiRDB data type name
- Exceptions
- None.
(e) getResultSet()
- Function
- Returns the ResultSet object containing the elements of a repetition column.
- Format
public ResultSet getResultSet()
- Arguments
- None.
- Return value
- ResultSet object
- Exceptions
- The JDBC driver throws an SQLException in the following cases:
- The PrdbResultSet object that created this PrdbArray object has been closed.
This includes the case where this driver has closed the PrdbResultSet object because the PrdbStatement object that created the PrdbResultSet object was closed.
- The Connection object used to create the PrdbStatement object, which created the PrdbResultSet object that created this PrdbArray object, is closed.
- An error occurred in the JDBC driver.
(f) getResultSet(long index,int count)
- Function
- Returns the ResultSet object containing the elements of a repetition column.
- Format
public ResultSet getResultSet(long index,int count) throws SQLException
- Arguments
- long index
- Index of the first element to be retrieved (the first element is 1)
- int count
- Number of consecutive array elements to be acquired
- Return value
- ResultSet object
- Functional detail
- This method returns the ResultSet object containing the elements of a repetition column.
- The ResultSet object contains at most as many consecutive elements of the repetition column as specified in count, beginning with the element specified in index.
- The following table shows the ResultSet object that is returned depending on the relationship between the index and count argument values:
index |
count |
(index+count) |
ResultSet that is returned |
0 < index number of elements |
0 count |
(index + count) - 1 number of elements |
Result set containing as many rows as specified in count |
(index -1 + count) - 1 > number of elements |
Result set containing as many rows as the number of elements - (index - 1) |
count < 0 |
-- |
SQLException is thrown |
index > number of elements |
-- |
-- |
SQLException is thrown |
index < 1 |
-- |
-- |
SQLException is thrown |
- Legend:
- --: Not applicable
- Exceptions
- The JDBC driver throws an SQLException in the following cases:
- The PrdbResultSet object that created this PrdbArray object has been closed.
This includes the case where this driver has closed the PrdbResultSet object because the PrdbStatement object that created the PrdbResultSet object was closed.
- The Connection object used to create the PrdbStatement object, which created the PrdbResultSet object that created this PrdbArray object, is closed.
- The specified index argument value is less than 1 or the count argument value is less than 0.
- The specified index argument value is greater than the number of elements.
(3) Package and class names
The names of the package and class for installing this interface are as follows:
- Package name: JP.co.Hitachi.soft.HiRDB.JDBC
- Class name: PrdbArray
All Rights Reserved. Copyright (C) 2011, Hitachi, Ltd.