Skip site navigation (1) Skip section navigation (2)

JDBC: allow update of Date-Columns with NULL

From: pgsql-bugs(at)postgresql(dot)org
To: pgsql-bugs(at)postgresql(dot)org
Subject: JDBC: allow update of Date-Columns with NULL
Date: 2000-08-29 08:44:10
Message-ID: 200008290844.e7T8iA205143@hub.org (view raw or flat)
Thread:
Lists: pgsql-bugs
Klaus Thiele (kth(at)pi-ag(dot)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

Next:From: The Hermit HackerDate: 2000-08-29 12:05:25
Subject: Re: [GENERAL] cannot vacuum a database !
Previous:From: Ange Michel POZZODate: 2000-08-29 08:23:55
Subject: cannot vacuum a database !

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group