I have a MS SQL Server DB I am reading data from and populating a bean. I hace a DATETIME Field in the DB and I get a Classcast Exception when I try to read it off my ResultSet. If anybody can share the code of how to get around this, it would be very helpful.
(I never got this problem in Oracle's DATE datatype - rs.getDate(COLUMN_NAME))
Please don't post the same question to multiple forums -- it just wastes people's time. Also, please use the appropriate forum for your questions: as this is a JDBC question, that's where I'll move it for you. I've already deleted the duplicates.
I think you will have to map it to timestamp, because datetime field will represent date and time both but as per java doc java.sql.Date is meant to represent date only.
From the javadoc
To conform with the definition of SQL DATE, the millisecond values wrapped by a java.sql.Date instance must be 'normalized' by setting the hours, minutes, seconds, and milliseconds to zero in the particular time zone with which the instance is associated.
visit this link . This document tell that datetime is mapped to timestamp in sql server. [ April 08, 2005: Message edited by: Shailesh Chandra ]