In java code how to insert Timestamp into DB2 (timestamp field)

alagappanK
alagappanK used Ask the Experts™
on
Hello

I am coding java program. My Database is DB2. I have a table with the field type Timestamp. How do I insert the current time into the field Timestamp using java. I know DB2 will recognize the word "current timestamp".

I would appreciate your help,

Kalagappan
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2016

Commented:
preparedStatement.setTimestamp(one_indexedParameterIndex, new java.sql.Timestamp());
Top Expert 2016
Commented:
Sorry

preparedStatement.setTimestamp(one_indexedParameterIndex, new java.sql.Timestamp(new java.util.Date().getTime()));

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial