8.4.35 Notes about the PreparedStatement interface
The PreparedStatement interface is a subinterface of the Statement interface. For this reason, the notes for the Statement interface also apply to the PreparedStatement interface.
This section describes additional notes that apply to the PreparedStatement interface.
- Organization of this subsection
(1) Dynamic parameter setup
-
For details about whether mapping is possible with a setXXX method, see (3) Mapping when a dynamic parameter is specified in 7.6.1 Mapping data types.
-
If the column number specified in a setXXX method does not exist, the JDBC driver throws an SQLException.
-
Overflow occurs when the value specified in a setXXX method exceeds the value range that can be represented by the data type of the corresponding dynamic parameter, resulting in an SQLException. For the combinations of a setXXX method and HADB data type that can cause overflow to occur, see 7.6.3 Overflow handling.
-
The values specified by a setXXX method remain effective until one of the following operations is executed:
-
The clearParameters method is executed for the target PreparedStatement object.
-
A setXXX method is executed for the target PreparedStatement object, and the dynamic parameters to be specified are the same.
-
The close method is executed for the target PreparedStatement object.
-
(2) Value specifications for dynamic parameters of HADB's DECIMAL type
This subsection describes the operations that are executed when a setXXX method is used to specify a value for a dynamic parameter of HADB's DECIMAL type, and when the precision and scaling of the dynamic parameter do not match the precision and scaling of the specified value.
-
When the precision of the specified value is greater than the actual precision: the JDBC driver throws an SQLException.
-
When the precision of the specified value is smaller than the actual precision: the JDBC driver increases the precision of the specified value.
-
When the scaling of the specified value is greater than the actual scaling: the JDBC driver truncates the specified scaling.
-
When the scaling of the specified value is smaller than the actual scaling: the JDBC driver increases the specified scaling by adding zeros.
(3) Value specifications for dynamic parameters of HADB's TIME and TIMESTAMP types
If a data type with a high fractional second precision is specified for a data type with a low fractional second precision, the differential fractional second precision is discarded. On the other hand, if a data type with a low fractional second precision is specified for a data type with a high fractional second precision, the resulting value is extended with zeros padded for the differential fractional second precision.
(4) Value specifications for dynamic parameters of HADB's CHAR and VARCHAR types
When a setXXX method is used to specify a value for a dynamic parameter of HADB's CHAR or VARCHAR type, and when the length of the value after conversion to a character string representation is greater than the defined length of the dynamic parameter, the JDBC driver throws an SQLException.
(5) Objects that can be specified with setObject
Objects of the following types can be specified for the x argument of the setObject method:
-
byte[]
-
java.lang.Byte
-
java.lang.Double
-
java.lang.Float
-
java.lang.Integer
-
java.lang.Long
-
java.lang.Short
-
java.lang.String
-
java.math.BigDecimal
-
java.sql.Boolean
-
java.sql.Date
-
java.sql.Time
-
java.sql.Timestamp