Archived

This topic is now archived and is closed to further replies.

HellCreator

[java] Date and jdbc

Recommended Posts

Hi Let say I have datetime or may be smalldaytame field in my retrieved recordset how I can retrieve this field and how to format it correctly as I know sql query style. Do I use select BOOKID,NAME, DATECOMPLETED convert(varchar,DATECOMPLETED,103) from books; and gets it in string field type or select * from books; without any converting so how i can get it right in objet Date Like if(rs.Next())//at least one record must be { int id=rs.getInt("BOOKID"); String name=rs.getString("NAME"); Date t=rs.?("DATECOMPLETED");//??? what the function }else { System.out.println("no record retrieved"); } Any sugestions pls? Can''t be root?Reboot! mount -r /home/hell

Share this post


Link to post
Share on other sites
Did you look in the API docs?
quote:

Date getDate(int columnIndex)
Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Date object in the Java programming language.
Date getDate(int columnIndex, Calendar cal)
Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Date object in the Java programming language.
Date getDate(String columnName)
Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Date object in the Java programming language.
Date getDate(String columnName, Calendar cal)
Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Date object in the Java programming language.
Time getTime(int columnIndex)
Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Time object in the Java programming language.
Time getTime(int columnIndex, Calendar cal)
Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Time object in the Java programming language.
Time getTime(String columnName)
Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Time object in the Java programming language.
Time getTime(String columnName, Calendar cal)
Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Time object in the Java programming language.
Timestamp getTimestamp(int columnIndex)
Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming language.
Timestamp getTimestamp(int columnIndex, Calendar cal)
Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming language.
Timestamp getTimestamp(String columnName)
Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object.
Timestamp getTimestamp(String columnName, Calendar cal)
Retrieves the value of the designated column in the current row of this ResultSet object as a java.sql.Timestamp object in the Java programming language.



java.sql.Date - is a date with no time.
java.sql.Time - is a time with no date.
java.sql.Timestamp - has both a date and a time.



First make it work, then make it fast. --Brian Kernighan

The problems of this world cannot possibly be solved by skeptics or cynics whose horizons are limited by the obvious realities. We need men and women who can dream of things that never were. - John Fitzgerald Kennedy(35th US President)

Do not interrupt your enemy when he is making a mistake. - Napolean Bonaparte

[edited by - CaptainJester on May 19, 2004 7:29:12 AM]

Share this post


Link to post
Share on other sites