Thread: JDBC: allow update of Date-Columns with NULL

JDBC: allow update of Date-Columns with NULL

From
pgsql-bugs@postgresql.org
Date:
Klaus Thiele (kth@pi-ag.com) reports a bug with a severity of 3
The lower the number the more severe it is.

Short Description
JDBC: allow update of Date-Columns with NULL

Long Description
JDBC: updating of Date (and other not_String)-columns with an null value throws an exception!
(this works with other jdbc-drivers (oracle, informix,...)


Sample Code
String updateStatement = "update table set datefield = ?";
prepStmt = con.prepareStatement(updateStatement);
prepStmt.setDate(1, datefield);  // datefield is null!!
prepStmt.executeUpdate();
==> "Exception: No value specified for parameter 1"

Solution:
add following code to "PreparedStatement.java":
in method "setDate()" (and others):
  // if the passed value is null, then set this column to null
  if(x==null)
     set(parameterIndex,"null");
  else {
     [...]


No file was uploaded with this report