Results 1 to 4 of 4

Thread: Cannot insert time into Oracle?

  1. #1
    Join Date
    Oct 2004
    Posts
    5

    Default 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. #2
    Join Date
    Aug 2004
    Posts
    1,104

    Default

    Use a java.sql.Timestamp - java.sql.Date does not have the time portion. Also, when you declare the parameter use Types.TIMESTAMP
    Thomas Risberg
    SpringSource by Pivotal
    http://www.springsource.org

  3. #3
    Join Date
    Oct 2004
    Posts
    5

    Default

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

  4. #4
    Join Date
    Jun 2005
    Posts
    19

    Default

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

Similar Threads

  1. MySQL DDL
    By analogueboy in forum Security
    Replies: 5
    Last Post: Aug 17th, 2007, 03:48 PM
  2. Insert Clob using Oracle
    By Anandhan in forum Data
    Replies: 13
    Last Post: Mar 28th, 2007, 06:30 AM
  3. Replies: 2
    Last Post: May 26th, 2005, 02:30 AM
  4. Replies: 2
    Last Post: May 5th, 2005, 09:35 PM
  5. Insert Blob into Oracle DB
    By pughbri in forum Data
    Replies: 9
    Last Post: Oct 11th, 2004, 03:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •