DB2 - Problem description
Problem IC65277 | Status: Closed |
USING THE JCC DRIVER, GETTIMESTAMP METHODS OF RESULTSET RETURN A SUBCLASS OF JAVA.SQL.TIMESTAMP | |
product: | |
DB2 FOR LUW / DB2FORLUW / 970 - DB2 | |
Problem description: | |
Users affected: Users of the IBM Data Server Driver for JDBC and SQLJ Problem Description: All connectivity types: The IBM Data Server Driver for JDBC and SQLJ released with DB2 for Linux, Unix, and Windows 9.7 Fixpack 1 returns a subclass of java.sql.Timestamp instead of java.sql.Timestamp for ResultSet.getTimestamp(int) or ResultSet.getTimestamp(String). This is perfectly normal and allowed by both Java and JDBC. ResultSet.getTimestamp(int, Calendar) and ResultSet.getTimestamp(String, Calendar) has done this in DB2 for Linux Unix and Windows 9.1 Fixpack releases. However, this change has caused a problem in a customer's application which depended on the name of the actual underlying class. This APAR provides an interim fix for the application's problem by returning java.sql.Timestamp instead of a subclass when ResultSet.getTimestamp(int) or ResultSet.getTimestamp(String) is called. Problem Summary: Unless you have this APAR change, if your application calls the getClass method on what is returned from a getTimestamp method, the getClass method will not necessarily return "java.sql.Timestamp" (but return the name of the subclass instead). Here is an example of a program whose behaviour depends on the class name that is returned by getTimestamp: import java.sql.*; public class IC65277 { public static void main( String arg[] ) { final String url = "<url>"; final String username = "<username>"; final String password = "<password>"; try { Class.forName("com.ibm.db2.jcc.DB2Driver"); Connection con = DriverManager.getConnection(url, username, password); Statement stmt = con.createStatement(); String query = "select current timestamp from sysibm.sysdummy1"; PreparedStatement pQuery = con.prepareStatement(query); ResultSet rs = pQuery.executeQuery(); while (rs.next()) { Object value = rs.getTimestamp(1); System.out.println(" Class = " + value.getClass()); System.out.println(" Result = " + value ); } } catch( Exception e ) { System.err.println( e ); } } } | |
Problem Summary: | |
**************************************************************** * USERS AFFECTED: * * Users of the IBM Data Server Driver for JDBC and SQLJ (also * * called the JCC driver) * **************************************************************** * PROBLEM DESCRIPTION: * * See Error Description * **************************************************************** * RECOMMENDATION: * * . * **************************************************************** | |
Local Fix: | |
The subclass of java.sql.Timestamp that is returned from getTimestamp can be used with any APIs that normally operate on a java.sql.Timestamp. So applications which call getTimestamp should normally need no change. | |
available fix packs: | |
DB2 Version 9.7 Fix Pack 2 for Linux, UNIX, and Windows | |
Solution | |
Problem was first fixed in Version 9.7 Fix Pack 2 | |
Workaround | |
The subclass of java.sql.Timestamp that is returned from getTimestamp can be used with any APIs that normally operate on a java.sql.Timestamp. So applications which call getTimestamp should normally need no change. | |
Timestamps | |
Date - problem reported : Date - problem closed : Date - last modified : | 22.12.2009 02.02.2011 02.02.2011 |
Problem solved at the following versions (IBM BugInfos) | |
9.7.FP2 | |
Problem solved according to the fixlist(s) of the following version(s) | |
9.7.0.2 |