Re: JDBC exception when call updateNull within an updateable ResultSet

Поиск
Список
Период
Сортировка
От Kris Jurka
Тема Re: JDBC exception when call updateNull within an updateable ResultSet
Дата
Msg-id Pine.LNX.4.33.0210141335540.30061-200000@leary.csoft.net
обсуждение исходный текст
Список pgsql-patches
The following patch allows an updateable result set to set values to null.
Since it is impossible to do hashtable.put(key, null), I have created a
special object to represent the null value.  This is simpler than creating
a separate collection to represent the fields set to null and trying to
keep that in sync with the regular values.

Thanks for the report.

Kris Jurka

On Fri, 11 Oct 2002, Olaf Liepelt wrote:

>
> Hi Kris, I've fund another bug. When creating an updateable result set
> and call 'updateNull' a NullPointerException is thrown: Exception in
> thread "main" java.lang.NullPointerException
>         at java.util.Hashtable.put(Hashtable.java:397)
>         at org.postgresql.jdbc2.AbstractJdbc2ResultSet.updateNull(AbstractJdbc2ResultSet.java:989)
>         at PGTest.main(PGTest.java:50)
>
> code:
>
> import java.sql.*;
>
> public class PGTest {
>     public static void main(String args[])
>         throws Exception
>     {
>         String sql = "create table t(a serial primary key, b int)";
>         Class.forName("org.postgresql.Driver");
>         Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/test", "comrad", "");
>         try
>         {
>             Statement stmt = conn.createStatement();
>             stmt.executeUpdate(sql);
>             sql = "INSERT INTO t (a, b) VALUES (3, 4)";
>             stmt.executeUpdate(sql);
>             stmt.close();
>         } catch (SQLException sqle)
>         {
>             sqle.printStackTrace();
>         }
>
>         try
>         {
>             sql = "select * from t for update";
>             Statement stmt = conn.createStatement();
>             ResultSet rs = stmt.executeQuery(sql);
>             rs.updateNull("b");
>             conn.commit();
>         } catch (SQLException sqle)
>         {
>             sqle.printStackTrace();
>         }
>
>         Statement stmt = conn.createStatement();
>         stmt.executeUpdate("DROP TABLE t");
>         stmt.executeUpdate("DROP sequence t_a_seq");
>         stmt.close();
>         conn.close();
>     }
> }
>
> Thanks Olaf
> --
> =============================
> | Olaf Liepelt              |
> | Sofware Innovations Ltd.  |
> | mail: olafl@comrad.co.nz  |
> =============================
>

В списке pgsql-patches по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: [HACKERS] ALTER TABLE ... ADD COLUMN
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: translation