how to insert date and time in oracle

hi,

i want to insert data&time in oracle i used following line

pstmt.setDate(4, new java.sql.Date(System.currentTimeMillis()));

it just save date after that i used following line but still getting date in db

pstmt.setTimestamp(4,new Timestamp(System.currentTimeMillis()));

in oracle i have date data type for field.

Please suggest me how i can save current time in oracle

regards

[433 byte] By [emmi@javaa] at [2007-11-27 7:43:38]
# 1

My Oracle is rusty, but this may partly depend on what version of Oracle you are using, and what the column type is: DATE versus DATETIME.

Also, if you want to insert the current date and time into a field, I would give that job to the DMBS and have it supplied in a trigger. But that's just my opinion...

Hippolytea at 2007-7-12 19:24:21 > top of Java-index,Java Essentials,Java Programming...
# 2
hi,i am using oracle10g and second you mean i use default value sysdate for coulmn?
emmi@javaa at 2007-7-12 19:24:21 > top of Java-index,Java Essentials,Java Programming...
# 3
>i am using oracle10g Good. What is the column's type?> and second you mean i use default value sysdate for coulmn?Yes. Relying on clients' timestamps gets you into trouble if two clientshaven't synchronized their watches!
Hippolytea at 2007-7-12 19:24:21 > top of Java-index,Java Essentials,Java Programming...
# 4
my column type is date but i see full date&time when i set sysdate but i want to set it through preparedstatement setdate or settimestamp.
emmi@javaa at 2007-7-12 19:24:21 > top of Java-index,Java Essentials,Java Programming...