JDBC: allow update of Date-Columns with NULL - Mailing list pgsql-bugs

From pgsql-bugs@postgresql.org
Subject JDBC: allow update of Date-Columns with NULL
Date
Msg-id 200008290844.e7T8iA205143@hub.org
Whole thread Raw
List pgsql-bugs
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

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: foreign_key regression test fails on Solaris 2.6
Next
From: Ange Michel POZZO
Date:
Subject: cannot vacuum a database !