Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

timestamp null

 
Annekee Dufour
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 724
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have to use IS NULL instead of = .
where timeStamp IS NULL
[ October 13, 2004: Message edited by: David Ulicny ]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think both the above mentioned option would work for you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic