Nonstop Database, HiRDB Version 9 UAP Development Guide

[Contents][Index][Back][Next]

18.4.8 ResultSetMetaData interface

Organization of this subsection
(1) Overview
(2) Methods
(3) Package and class names
(4) Notes

(1) Overview

The ResultSetMetaData interface provides the following principal function:

(2) Methods

The table below lists the methods of the ResultSetMetaData 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-46 ResultSetMetaData interface methods

Subsection Method Function
(a) getCatalogName(int column) Returns the catalog name for a specified column number of a table.
(b) getColumnClassName(int column) Returns the fully specified Java class name for a specified column.
(c) getColumnCount() Returns the number of columns in this ResultSet object.
(d) getColumnDisplaySize(int column) Returns a specified column's maximum width (in characters).
(e) getColumnLabel(int column) Returns a recommended print or display title for a specified column.
(f) getColumnName(int column) Returns a specified column's column name.
(g) getColumnType(int column) Returns a specified column's SQL data type.
(h) getColumnTypeName(int column) Returns a specified column's database-specific format name.
(i) getPrecision(int column) Returns a specified column's length in decimal digits.
(j) getScale(int column) Returns the number of decimal places in a specified column.
(k) getSchemaName(int column) Returns a specified column's table schema.
(l) getTableName(int column) Returns the table name for a specified column.
(m) isAutoIncrement(int column) Returns a value indicating whether a specified column is both numbered automatically and treated as being read-only.
(n) isCaseSensitive(int column) Returns a value indicating whether a specified column is case sensitive.
(o) isCurrency(int column) Returns a value indicating whether a specified column is for currency values.
(p) isDefinitelyWritable(int column) Returns a value indicating whether write operations on a specified column will be successful.
(q) isNullable(int column) Returns a value indicating whether the NULL value can be set in a specified column.
(r) isReadOnly(int column) Returns a value indicating whether a specified column's value is read-only.
(s) isSearchable(int column) Returns a value indicating whether a specified column can be used in a where section.
(t) isSigned(int column) Returns a value indicating whether a specified column is for signed numeric values.
(u) isWritable(int column) Returns a value indicating whether write operations on a specified column can be successful.
(a) getCatalogName(int column)

Function
Returns the catalog name for a specified column number of a table.

Format
 
public synchronized String getCatalogName(int column) throws SQLException
 

Arguments
int column
Column number (beginning with 1)

Return value
String object

Functional detail
This method always returns null.

Exceptions
If the specified column value is 0 or less or is greater than the number of columns, the JDBC driver throws an SQLException.
(b) getColumnClassName(int column)

Function
Returns the fully specified Java class name for a specified column.

Format
 
public synchronized String getColumnClassName(int column) throws SQLException
 

Arguments
int column
Column number (beginning with 1)

Return value
String object

Functional detail
This method returns the result of executing the ResultSet#getObject method on a column as the String Java class type. The following table shows the return value depending on the column's data type.

Table 18-47 Character strings returned by getColumnClassName

Column's HiRDB data type Character string returned
BLOB "java.lang.Object"
BINARY "java.lang.Object"
INTEGER "java.lang.Integer"
SMALLINT "java.lang.Integer"
FLOAT
DOUBLE PRECISION
"java.lang.Double"
SMALLFLT
REAL
"java.lang.Float"
DECIMAL
NUMERIC
"java.math.BigDecimal"
CHAR "java.lang.String"
MCHAR "java.lang.String"
NCHAR "java.lang.String"
VARCHAR "java.lang.String"
MVARCHAR "java.lang.String"
NVARCHAR "java.lang.String"
DATE "java.sql.Date"
TIME "java.sql.Time"
TIMESTAMP "java.sql.Timestamp"
BOOLEAN (column found only in a ResultSet created from DatabaseMetaData) "java.lang.Boolean"

Exceptions
If the specified column value is 0 or less or is greater than the number of columns, the JDBC driver throws an SQLException.
(c) getColumnCount()

Function
Returns the number of columns in this ResultSet object.

Format
 
public synchronized int getColumnCount()
 

Arguments
None.

Return value
int type:
Number of columns

Exceptions
None.
(d) getColumnDisplaySize(int column)

Function
Returns a specified column's maximum width (in characters)

Format
 
public synchronized int getColumnDisplaySize(int column) throws SQLException
 

Arguments
int column
Column number beginning at 1

Return value
int type:
Maximum number of characters

Functional detail
This method returns the maximum width of a specified column in characters. The following table shows the maximum width (in number of characters) returned by getColumnDisplaySize.

Table 18-48 Maximum width (in number of characters) returned by getColumnDisplaySize

Column's HiRDB data type Maximum width returned (number of characters)
BLOB(n)
BINARY(n)
n
INTEGER 11
SMALLINT 6
FLOAT
DOUBLE PRECISION
23
SMALLFLT
REAL
13
DECIMAL(n,m)
NUMERIC(n,m)
n + 2
CHAR(n)
MCHAR(n)
NCHAR(n)
VARCHAR(n)
MVARCHAR(n)
NVARCHAR(n)
n
DATE 10
TIME 8
TIMESTAMP(n) n > 0: 19 + (n + 1)
n = 0: 19
BOOLEAN (column found only in a ResultSet created from DatabaseMetaData) 5

Exceptions
If the specified column value is 0 or less or is greater than the number of columns, the JDBC driver throws an SQLException.
(e) getColumnLabel(int column)

Function
Returns a recommended print or display title for a specified column.
This method returns the column name, which is the same value returned by PrdbResultSetMetaData#getColumnName. For details, see (f) getColumnName(int column).

Format
 
public synchronized String getColumnLabel(int column) throws SQLException
 

Arguments
int column
Column number (beginning with 1)

Return value
String object

Exceptions
If the specified column value is 0 or less or is greater than the number of columns, the JDBC driver throws an SQLException.
(f) getColumnName(int column)

Function
Returns a specified column's column name.

Format
 
public synchronized String getColumnName(int column) throws SQLException
 

Arguments
int column
Column number beginning at 1

Return value
String object

Functional detail
This method returns the applicable contents from the HiRDB Column Name Descriptor Area (SQLCNDA) as the name of the specified column. The method acquires the name from SQLNAME in SQLCNDA that is sent from the HiRDB server to this driver (and converts the name to Java's internal code) and then returns the result. Note that if a set function, value expression, or WRITE specification is used in the SELECT statement, only the first 28 bytes are returned and any additional bytes are discarded during communication between server and client. This driver ignores any of the following characters at the beginning of a name that is received from the HiRDB server:
  • [Figure] [Figure]
  • [Figure] [Figure]
Legend: [Figure]: Single-byte space, [Figure]: 0xff
For details about this method's return value, see Appendix C.1 Organization and contents of the Column Name Descriptor Area.
The first column of a ResultSet class acquired from an Array object is created by the JDBC driver and JDBC_Array_Index is returned as its column name.

Exceptions
If the specified column value is 0 or less or is greater than the number of columns, the JDBC driver throws an SQLException.
(g) getColumnType(int column)

Function
Returns a specified column's SQL data type. For the correspondence between the column data types and the return values, see 18.8.1 Mapping SQL data types.

Format
 
public synchronized int getColumnType(int column) throws SQLException
 

Arguments
int column
Column number (beginning with 1)

Return value
int type:
SQL type from java.sql.Types

Exceptions
If the specified column value is 0 or less or is greater than the number of columns, the JDBC driver throws an SQLException.
(h) getColumnTypeName(int column)

Function
Returns a specified column's database-specific format name.

Format
 
public synchronized String getColumnTypeName(int column) throws SQLException
 

Arguments
int column
Column number (beginning with 1)

Return value
String object

Functional detail
This method returns a specified column's database-specific format name. The following table shows the column data types and return values.

Table 18-49 Character strings returned by getColumnTypeName

Column's HiRDB data type Character string returned
BLOB "BLOB"
BINARY "BINARY"
INTEGER "INTEGER"
SMALLINT "SMALLINT"
FLOAT "FLOAT"
REAL "REAL"
DECIMAL "DECIMAL"
CHAR "CHAR"
MCHAR "MCHAR"
NCHAR "NCHAR"
VARCHAR "VARCHAR"
MVARCHAR "MVARCHAR"
NVARCHAR "NVARCHAR"
DATE "DATE"
TIME "TIME"
TIMESTAMP "TIMESTAMP"
BOOLEAN (column found only in a ResultSet created from DatabaseMetaData) "BOOLEAN"

Exceptions
If the specified column value is 0 or less or is greater than the number of columns, the JDBC driver throws an SQLException.
(i) getPrecision(int column)

Function
Returns a specified column's length in decimal digits.

Format
 
public synchronized int getPrecision(int column) throws SQLException
 

Arguments
int column
Column number (beginning with 1)

Return value
int type:
Column length in decimal digits

Functional detail
If the specified column has a numeric data type (INTEGER, SMALLINT, FLOAT, DOUBLE PRECISION, SMALLFLT, REAL, DECIMAL, or NUMERIC), this method returns the number of decimal digits. If it does not have a numeric data type, the method returns the column length in bytes. The following table shows the return value of getPrecision.

Table 18-50 Return value of getPrecision

Column's HiRDB data type Return value
BLOB(n), BINARY(n) n
INTEGER 10
SMALLINT 5
FLOAT, DOUBLE PRECISION 15
SMALLFLT, REAL 7
DECIMAL(n,m), NUMERIC(n,m) n
CHAR(n), MCHAR(n), VARCHAR(n), MVARCHAR(n) n
NCHAR(n), NVARCHAR(n) n x 2
DATE 10
TIME 8
TIMESTAMP(n) n > 0: 19 + (n + 1)
n = 0: 19
BOOLEAN (column found only in a ResultSet created from DatabaseMetaData) 1

Exceptions
If the specified column value is 0 or less or is greater than the number of columns, the JDBC driver throws an SQLException.
(j) getScale(int column)

Function
Returns the number of decimal places in a specified column.

Format
 
public synchronized int getScale(int column) throws SQLException
 

Arguments
int column
Column number (beginning with 1)

Return value
int type:
Column's number of decimal places

Functional detail
This method returns the number of decimal places in a specified column. The following table shows the return value depending on the data type.

Table 18-51 Value returned by getScale

Column's HiRDB data type Return value
DECIMAL
NUMERIC
Decimal places
TIMESTAMP Number of digits below a millisecond
Other 0

Exceptions
If the specified column value is 0 or less or is greater than the number of columns, the JDBC driver throws an SQLException.
(k) getSchemaName(int column)

Function
Returns a specified column's table schema.

Format
 
public synchronized String getSchemaName(int column) throws SQLException
 

Arguments
int column
Column number (beginning with 1)

Return value
String object

Functional detail
This method always returns null.

Exceptions
If the specified column value is 0 or less or is greater than the number of columns, the JDBC driver throws an SQLException.
(l) getTableName(int column)

Function
Returns the table name for a specified column.

Format
 
public synchronized String getTableName(int column) throws SQLException
 

Arguments
int column
Column number (beginning with 1)

Return value
String object

Functional detail
This method always returns null.

Exceptions
If the specified column value is 0 or less or is greater than the number of columns, the JDBC driver throws an SQLException.
(m) isAutoIncrement(int column)

Function
Returns a value indicating whether a specified column is both numbered automatically and treated as being read-only.

Format
 
public synchronized boolean isAutoIncrement(int column) throws SQLException
 

Arguments
int column
Column number (beginning with 1)

Return value
boolean type:
true: The specified column is numbered automatically and is treated as being read-only.
false: The specified column is not numbered automatically or is not treated as being read-only.

Functional detail
This method always returns false.

Exceptions
If the specified column value is 0 or less or is greater than the number of columns, the JDBC driver throws an SQLException.
(n) isCaseSensitive(int column)

Function
Returns a value indicating whether a specified column is case sensitive.

Format
 
public synchronized boolean isCaseSensitive(int column) throws SQLException
 

Arguments
int column
Column number (beginning with 1)

Return value
boolean type:
true: The column is case sensitive.
false: The column is not case sensitive.

Functional detail
This method always returns false.

Exceptions
If the specified column value is 0 or less or is greater than the number of columns, the JDBC driver throws an SQLException.
(o) isCurrency(int column)

Function
Returns a value indicating whether a specified column is for currency values.

Format
 
public synchronized boolean isCurrency(int column) throws SQLException
 

Arguments
int column
Column number (beginning with 1)

Return value
boolean type:
true: The column is for currency values.
false: The column is not for currency values.

Functional detail
This method always returns false.

Exceptions
If the specified column value is 0 or less or is greater than the number of columns, the JDBC driver throws an SQLException.
(p) isDefinitelyWritable(int column)

Function
Returns a value indicating whether write operations on a specified column will be successful.

Format
 
public synchronized boolean isDefinitelyWritable(int column) throws SQLException
 

Arguments
int column
Column number (beginning with 1)

Return value
boolean type:
true: Write operations on the column will be successful.
false: Write operations on the column might not be successful.

Functional detail
This method always returns false.

Exceptions
If the specified column value is 0 or less or is greater than the number of columns, the JDBC driver throws an SQLException.
(q) isNullable(int column)

Function
Returns a value indicating whether the NULL value can be set in a specified column.

Format
 
public synchronized int isNullable(int column) throws SQLException
 

Arguments
int column
Column number (beginning with 1)

Return value
int type:
ResultSetMetaData.columnNoNulls: The NULL value cannot be set.
ResultSetMetaData.columnNullable: The NULL value can be set.

Exceptions
If the specified column value is 0 or less or is greater than the number of columns, the JDBC driver throws an SQLException.
(r) isReadOnly(int column)

Function
Returns a value indicating whether a specified column's value is read-only.

Format
 
public synchronized boolean isReadOnly(int column) throws SQLException
 

Arguments
int column
Column number (beginning with 1)

Return value
boolean type:
true: The specified column's value is read-only.
false: The specified column's value might not be read-only.

Functional detail
This method always returns false.

Exceptions
If the specified column value is 0 or less or is greater than the number of columns, the JDBC driver throws an SQLException.
(s) isSearchable(int column)

Function
Returns a value indicating whether a specified column can be used in a where section.

Format
 
public synchronized boolean isSearchable(int column) throws SQLException
 

Arguments
int column
Column number (beginning with 1)

Return value
boolean type:
true: The column can be used in a where section.
false: The column cannot be used in a where section.

Functional detail
If the ResultSet was created from DatabaseMetaData, the method returns false.
If the ResultSet was not created from DatabaseMetaData, the method returns true.

Exceptions
If the specified column value is 0 or less or is greater than the number of columns, the JDBC driver throws an SQLException.
(t) isSigned(int column)

Function
Returns a value indicating whether a specified column is for signed numeric values.

Format
 
public synchronized boolean isSigned(int column) throws SQLException
 

Arguments
int column
Column number (beginning with 1)

Return value
boolean type:
true: The column is for signed numeric values.
false: The column is not for signed numeric values.

Functional detail
This method returns a value indicating whether a specified column is for signed numeric values. The following table shows the return value depending on the column's data type.

Table 18-52 Value returned by isSigned

Column's HiRDB data type Return value
INTEGER
SMALLINT
FLOAT
DOUBLE PRECISION
REAL
SMALLFLT
DECIMAL
NUMERIC
true
Other false

Exceptions
If the specified column value is 0 or less or is greater than the number of columns, the JDBC driver throws an SQLException.
(u) isWritable(int column)

Function
Returns a value indicating whether write operations on a specified column can be successful.

Format
 
public synchronized boolean isWritable(int column) throws SQLException
 

Arguments
int column
Column number (beginning with 1)

Return value
boolean type:
true: Write operations on the column can be successful.
false: Write operations on the column cannot be successful.

Functional detail
This method always returns false.

Exceptions
If the specified column value is 0 or less or is greater than the number of columns, the JDBC driver throws an SQLException.

(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: PrdbResultSetMetaData

(4) Notes

(a) getColumnName and getColumnLabel methods

The getColumnName and getColumnLabel methods get retrieval item names from SQLNAME in the Column Name Descriptor Area (SQLCNDA) that the HiRDB driver sends to the JDBC driver. The methods then convert the names to Java internal codes and return them. For a description of the return values of these methods for specified columns, see C.1 Organization and contents of the Column Name Descriptor Area.