473,226 Members | 1,532 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,226 software developers and data experts.

JAVA :: Timestamp from DB2

Hi,
is there any possibility to get a Timestamp in Java from the DB2-System?
(not from a table)

Thanks for help.

Andreas
Nov 12 '05 #1
5 13998
You can use SELECT CURRENT TIMESTAMP FROM SYSIBM.SYSDUMMY1 in many
(all?) versions of DB2. This doesn't require access to any user tables.

Check the "SET" statement in SQL Reference V.2 (LUW).

VALUES(CURRENT TIMESTAMP) will also generate a row that has what you
want but I've never tried retrieving the row in Java.
Phil Sherman
Andreas wrote:
Hi,
is there any possibility to get a Timestamp in Java from the DB2-System?
(not from a table)

Thanks for help.

Andreas


Nov 12 '05 #2

"Andreas" <di************@handshake.de> wrote in message
news:9c**************************@posting.google.c om...
Hi,
is there any possibility to get a Timestamp in Java from the DB2-System?
(not from a table)

The following code will work, assuming you have already instantiated the
connection, named parmConn in this case:

ResultSet rs = null;

Statement stmt = null;

/* Get the current timestamp. */

try {

String query = "Values(current timestamp)";

stmt = parmConn.createStatement();

rs = stmt.executeQuery(query);
System.out.println("");

System.out.print(query + ": ");

while (rs.next()) {

System.out.print(rs.getTimestamp(1)); //display timestamp

System.out.println("");

}

stmt.close();

rs.close();

}

catch (SQLException sql_excp) {

sql_excp.printStackTrace();

}

The output I got when I ran it was:

Values(current timestamp): 2004-10-19 12:13:11.901

Rhino
Nov 12 '05 #3

The output I got when I ran it was:

Values(current timestamp): 2004-10-19 12:13:11.901

Sorry, that wasn't the best example of output. Normally, the fractional part
of the seconds would be six digits, not 3. I just happened to run that query
at exactly 12:13:11 and 901 microseconds. Here is a more typical output:

Values(current timestamp): 2004-10-19 14:39:57.283002

Rhino
Nov 12 '05 #4
Hi,
thank You very much for the fast help.

I'll try it asap (at the moment I haven't access to the DB2-System)... ;-)

Andreas
Nov 12 '05 #5

"Andreas" <di************@handshake.de> wrote in message
news:9c**************************@posting.google.c om...
Hi,
thank You very much for the fast help.
My pleasure!
I'll try it asap (at the moment I haven't access to the DB2-System)... ;-)

Rhino
Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Phil Powell | last post by:
I am forced to have to compare the value of some PHP timestamp with a Java-based java.util.Date.getTime() timestamp. Let me show you how they look: The Java time is returned to the PHP...
1
by: Roberto Nenni | last post by:
hi all and sorry for my english I write into a SqlServer2000 database via jdbc using a PreparedStatement (pstmt) and one of fields is a TimeStamp, my code is: qwdum=System.currentTimeMillis();...
0
by: Michael Welp | last post by:
Hallo NG, i have a problem with a Timestamp field. I use a JDBC Type 4 - Driver. When i make a select on a table with a timestamp-field i got for example the result : 2004-04-30 15:23:44.0 ...
2
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered...
2
by: Michael | last post by:
Running DB2 v7 UDB ("DB2 v7.1.0.93", "n031208" and "WR21333") on Windows XP, I am unable to find out why the "Build for Debug" option within Stored Procedure Builder is not enabled on Java stored...
2
by: Chris | last post by:
Hi, I seem to be having some problems connecting to webservices. I'm running a C# client connected to a Java webservice using GLUE. The difference between the two request and response pairs...
1
by: keyjen2017 | last post by:
i am trying to read the table in DB2 using JAVA code. then it is supposed to be copied in .txt file. how can i do this? other thing, i m passing date in dddd-mm-yy format from JAVA codeto call a ...
2
ruch095
by: ruch095 | last post by:
i'm student and my project work about RTP Protocol (Develop with java),now i want a algorithm for calculate NTP timestamp(header of rtcp protocol).Anybody who have this algorithm,please tell me. ...
6
by: tak | last post by:
Hi. I have a client / server application, which the client will send the server a timestamp everytime when there is a transaction. The client is using Java, and it sends the timestamp using...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.