File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC 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
Bookmark "Getting timestamp from the DB" Watch "Getting timestamp from the DB" New topic
Author

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.
Thanks!
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30531
    
150

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


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, 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: http://aspose.com/file-tools
 
subject: Getting timestamp from the DB