Announcement Announcement Module
Collapse
No announcement yet.
Cannot insert time into Oracle? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cannot insert time into Oracle?

    Was anyone able to insert date AND time into Oracle when using SqlUpdate (a class that extends it)? In my Object[] arguments, I've tried to pass in both a java.util.Date and a java.sql.Date object to the update function - both results in a successful insert in the database for the DATE but the TIME portion is "missing"...

    Say, my argument in the Object[] is
    Code:
     new Date(System.currentTimeMillis())
    If I query the record using to_char(mydate, 'YYYY-MM-DD HH:MI:SS') after the insert, Oracle shows 2005-06-08 12:00:00 - so the date is correct but the time is not what I expected.

    Any input will be much appreciated.

    piko

  • #2
    Use a java.sql.Timestamp - java.sql.Date does not have the time portion. Also, when you declare the parameter use Types.TIMESTAMP

    Comment


    • #3
      Thanks for the quick reply, Thomas! It works as you said. :P

      Comment


      • #4
        Alternatively, use java.util.Calendar. I ran into this issue, too. IIRC, Calendar is somewhat of a replacement for the (limited) Date class.

        Comment

        Working...
        X