"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