My blog has moved! Redirecting...

You should be automatically redirected. If not, visit http://mindsiview.wordpress.com/ and update your bookmarks.

Tuesday, June 15, 2004

Java Quick Tip of the Day: Selecting Current TimeStamp for DB2

There are times when you may want multiple programs to retrieve a current timestamp from a central location. This can be accomplished by selecting the timestamp from a database server. To return the current timestamp from DB2 execute the following query:

     ResultSet rs;
     rs = stmt.executeQuery("select distinct(current timestamp)
          from sysibm.sysdummy1");
     rs.next();
     java.util.Date today = rs.getTimestamp(1);

Notice that I used a table called "sysibm.sysdummy1". Sysdummy1 is a special purpose table for uses such as this one. Additionally, you can use any db2 table that you have access to.

No comments:

Technorati search