반응형


jdbc에서 resultSet.getDate() 하면 new java.util.Date();
 - 시간, 분, 초 정보는 가지고 있지 않다.

ResultSet 의 메소드를 살펴 보면.

java.sql.ResultSet


public abstract Date getDate(String columnName) throws SQLException
 Get the value of a column in the current row as a java.sql.Date object.
 Returns: the column value; if the value is SQL NULL, the result is null


public abstract Time getTime(String columnName) throws SQLException
 Get the value of a column in the current row as a java.sql.Time object.
 Returns: the column value; if the value is SQL NULL, the result is null

getDate() 나 getTime() 은 java.util.Date 객체를 반환하는 것이 아니라
java.sql 패키지의 java.sql.Date와 java.sql.Time 객체를 반환하고 있습니다.


반면

public abstract Timestamp getTimestamp(String columnName) throws SQLException
 Get the value of a column in the current row as a java.sql.Timestamp object.
 Returns: the column value; if the value is SQL NULL, the result is null


getTimestamp() 는 "java.sql.Date, java.sql.Time, java.sql.Timestamp 는 java.util.Date를 상속받아서
모든 정보를 가지고 있다.



2009.10.21 00:00:00  <-- rs.getDate()
1970.01.01 01:15:38  <-- rs.getTime()
2009.10.21 01:15:38  <-- rs.getTimestamp()

반응형

'프로그래밍 > Java' 카테고리의 다른 글

외부 명령어 실행  (1) 2010.01.29
순서 보장 되는 HashMap  (0) 2009.11.19
[CVS] 이클립스에서 CVS 생성하기.  (0) 2009.08.04
IOStream 관련..  (0) 2009.07.21
[log4j] log4j 에 대한 설명.  (0) 2009.07.10

+ Recent posts