File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Getting timestamp from the DB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Getting timestamp from the DB" Watch "Getting timestamp from the DB" New topic

Getting timestamp from the DB

Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
Hi. I have an app, that requires me to do a batch update. The batch update works great. I've run into one problem, however. In my stored procedure, I am setting a variable with the current timestamp. My problem is, this timestamp changes with each time a batch statement runs. Say I have 20 statements I am sending to my procedure, I want one timestamp value to be the same on all these rows when they are inserted into the database.
Can't use the PC time - need the Database time.
Is there any way within the java app to get the date from the database, maybe through meta data, or something else?

Please let me know if you have any suggestions.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33106

You could do one query to get the system time on the database. Then pass that as a parameter for each batched statement.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Jennifer Sohl
Ranch Hand

Joined: Feb 28, 2001
Posts: 455
That sounds like a good idea. Thanks for the help!
I agree. Here's the link:
subject: Getting timestamp from the DB
It's not a secret anymore!