How to set java.sql.Date to null ? - Mailing list pgsql-general

From Kapoor, Nishikant X
Subject How to set java.sql.Date to null ?
Date
Msg-id C7DCBA49A357D11196A500805F851ACD0146163E@MNMAIL04
Whole thread Raw
Responses Re: [INTERFACES] How to set java.sql.Date to null ?
List pgsql-general
Hi there

I'm trying to pass a java.sql.Date parameter to a sql query using
JDBC-PostgreSQL interface. The problem shows up when I pass a null
java.sql.Date but as it happens in my application, the user may or may
not
enter the logDate.
(It works fine if the java.sql.Date(logDate) is a valid date).
Here is the code:

    PreparedStatement pstmt = null;
    try {
      pstmt = connect.prepareStatement("insert into prfs (prfNo, author,
severity, blockFunc, probArea, status, probDesc, logDate, estCompDate,
actCompDate, assigned, assignee,
 solution, attachment, siemensVar, reviewer) values " +
"(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)" );

      pstmt.setString(1,  prfNo);
      pstmt.setString(2,  author);
      pstmt.setInt(3,     severity);
      pstmt.setInt(4,     blockFunc);
      pstmt.setInt(5,     probArea);
      pstmt.setInt(6,     status);
      pstmt.setString(7,  probDesc);
-->   pstmt.setDate(8,    logDate); <-- NullPointerException ex
    } catch (SQLException e) { }


How do I set a Date to be a null ?

Thanks
Nishi

--------To err is human but to really mess it up is computer--------
mailto:nishikant.x.kapoor@nspco.com   http://www.c3ipros.com/nkapoor
-----------------------------------~~~------------------------------


pgsql-general by date:

Previous
From: "Krasnow, Greg"
Date:
Subject: default date
Next
From: "John E. Garrott"
Date:
Subject: Re: [GENERAL] psql problem