This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JDBC and the fly likes How to insert automatic timestamp? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to insert automatic timestamp?" Watch "How to insert automatic timestamp?" New topic
Author

How to insert automatic timestamp?

Mike Dafel
Greenhorn

Joined: Jul 12, 2001
Posts: 10
Hi,
I want to insert an automatic timestamp(consisting of date & time) in my table using JDBC. I am writing servlets to poulate my tables. Could anybody provide a code snippet to include in my servlets. Please help as I am confused between java.util.Date and java.sql.Date. I don't know how to use them as I couldn't find an example anywhere.
Thanks in advance.
Napa Sreedhar
Ranch Hand

Joined: Jan 29, 2002
Posts: 62
If you have a Date column in your database table then construct the query as
String stmt = "insert in to my_table "
+ " values(?, ?, ... , SYSDATE)";
...
...
If you want to append the time stamp to some VARCHAR2 column, then obtain a String using java.util.Date and insert the column as a String.
Hope this helps.
Napa
 
 
subject: How to insert automatic timestamp?
 
Similar Threads
window timestamp
Syslog collection
how i can create a TimeStamp from a number like: 1183450890250, or how insert it ?
Optimistic concurrency in hibernate using version/timestamp.
gps week/seconds conversion