Table 29. Examples of updating DATE, TIME, or TIMESTAMP SQL values with Java date, time, or timestamp values
that do not represent real dates or times (continued)
String input value
Target type in
database Value sent to table column, or exception
25:00:00 TIME 01:00:00
24:00:00 TIME 00:00:00
2008-15-36
28:63:74.0
TIMESTAMP 2009-04-06 05:04:14.0
9999-12-31
24:00:00.0
TIMESTAMP Exception, because the adjusted value (10000-01-01 00:00:00.0) exceeds the
maximum year of 9999.
The following examples demonstrate the results of retrieving data from
TIMESTAMP columns in JDBC or SQLJ applications, when the values in those
columns do not represent real dates or times.
Table 30. Results of retrieving DATE, TIME, or TIMESTAMP SQL values that do not represent real dates or times into
Java application variables
SELECT statement
Value in TIMESTAMP
column TS_COL
Target type in
application (getXXX
method for retrieval) Value retrieved from table column
SELECT TS_COL
FROM TABLE1
2000-01-01 24:00:00.000000 java.sql.Timestamp
(getTimestamp)
2000-01-02 00:00:00.000000
SELECT TS_COL
FROM TABLE1
2000-01-01 24:00:00.000000 String (getString) 2000-01-02 00:00:00.000000
SELECT
CHAR(TS_COL)
FROM TABLE1
2000-01-01 24:00:00.000000 java.sql.Timestamp
(getTimestamp)
2000-01-02 00:00:00.000000
SELECT
CHAR(TS_COL)
FROM TABLE1
2000-01-01 24:00:00.000000 String (getString) 2000-01-01 24:00:00.000000 (no adjustment
by Java)
Related reference
“JDBC differences between the current IBM Data Server Driver for JDBC and
SQLJ and earlier DB2 JDBC drivers” on page 370
Properties for the IBM Data Server Driver for JDBC and SQLJ
IBM Data Server Driver for JDBC and SQLJ properties define how the connection
to a particular data source should be made. Most properties can be set for a
DataSource object or for a Connection object.
Methods for setting the properties
Properties can be set in one of the following ways:
v Using setXXX methods, where XXX is the unqualified property name, with the
first character capitalized.
Properties are applicable to the following IBM Data Server Driver for JDBC and
SQLJ-specific implementations that inherit from
com.ibm.db2.jcc.DB2BaseDataSource:
– com.ibm.db2.jcc.DB2SimpleDataSource
– com.ibm.db2.jcc.DB2ConnectionPoolDataSource
– com.ibm.db2.jcc.DB2XADataSource
Chapter 7. JDBC and SQLJ reference information 201
|
|
|
|
||
|||
|||
|
|
||
|
|
||
|
|
|
|
|
|
|
|
|
|
|
|
|
||
|
|
||
|
|
|
|
|||
|
|
|
||
|
|
|
|
|
|||
|
|
|
|
|