8.7.10 getPrecision(int column)
- Organization of this subsection
(1) Function
This method acquires a specified column's length (in digits).
(2) Format
public synchronized int getPrecision(int column) throws SQLException
(3) Arguments
- int column
-
Specifies a column number (where the first column is 1).
(4) Return value
The method returns the specified column's length in decimal digits. If the specified column has a numeric data type, the method returns the number of digits. If it does not have a numeric data type, the method returns the column length in bytes. The following table shows the return values of the getPrecision method.
Column's data type (HADB data type) |
Return value (column length in digits) |
---|---|
INTEGER |
19 |
SMALLINT |
10 |
5#1 |
|
DOUBLE PRECISION |
17 |
DECIMAL(m,n) |
m |
CHAR(n) VARCHAR(n) |
n |
DATE |
10 |
TIME(p) |
p = 0: 8 p > 0: 8 + (n + 1) |
TIMESTAMP(p) |
p = 0: 19 p > 0: 19 + (n + 1) |
BINARY(n) VARBINARY(n) |
n |
ROW |
row-length#2 |
BOOLEAN (column found only in a ResultSet created from DatabaseMetaData) |
1 |
- #1
-
This column is found only in a ResultSet created from DatabaseMetaData. If the column's data type is defined as short, this value is returned.
- #2
-
Sum of the data lengths of all columns. For details about how to obtain the data length of a column, see the topic List of data types in the manual HADB SQL Reference.
(5) Exceptions
If the specified column value is 0 or less, or is greater than the number of columns in the table, the JDBC driver throws an SQLException.