Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

difference between java.sql.time and java.sql.timestamp in java  RSS feed

 
reubin haz
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a DB table, with a column of type Time.
I'm wondering in the JDBC, should I use java.sql.Time or java.sql.Timestamp to save this column value?

Which one is better? Thanks.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 36621
474
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depends on what you want to save. If just time, java.sql.Time. If date and time, TimeStamp.

The database time type implies just time, but the exact meaning could vary based on the database.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!