File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes timestamp null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "timestamp null" Watch "timestamp null" New topic

timestamp null

Annekee Dufour
Ranch Hand

Joined: Nov 04, 2003
Posts: 41
I want to get all entries from a table in db2 where a certain timestamp is not set. If I use a query "select something, myTimestamp from myTable", and I print myResultSet.getTimeStamp("myTimestamp"), the answer is null;

However, if I try to select all the empty timestamps with a preparedStatement:
preparedStatement = "select something from myTable where myTimestamp=?";
preparedStatement.setTimeStamp(1, null);
I do not get any results!
Does anybody know how can I find the empty timestamps?
David Ulicny
Ranch Hand

Joined: Aug 04, 2004
Posts: 724
You have to use IS NULL instead of = .
where timeStamp IS NULL
[ October 13, 2004: Message edited by: David Ulicny ]

SCJP<br />SCWCD <br />ICSD(286)<br />MCP 70-216
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63866

Although I've never tried it, you might want to try out the setNull() method of the PreparedStatement to see if that suits your needs.

[Asking smart questions] [About Bear] [Books by Bear]
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
i think both the above mentioned option would work for you.
I agree. Here's the link:
subject: timestamp null
It's not a secret anymore!