JDBC: allow update of Date-Columns with NULL

Поиск
Список
Период
Сортировка
От pgsql-bugs@postgresql.org
Тема JDBC: allow update of Date-Columns with NULL
Дата
Msg-id 200008290844.e7T8iA205143@hub.org
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: foreign_key regression test fails on Solaris 2.6
Следующее
От: Ange Michel POZZO
Дата:
Сообщение: cannot vacuum a database !