• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to insert automatic timestamp?

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic