Обсуждение: FW: (repost) using null value timestamps

Поиск
Список
Период
Сортировка

FW: (repost) using null value timestamps

От
"Scott Muir"
Дата:
anyone?

Scott.

-----Original Message-----
From: pgsql-interfaces-owner@postgresql.org
[mailto:pgsql-interfaces-owner@postgresql.org]On Behalf Of Scott Muir
Sent: August 13, 2001 7:17 PM
To: pgsql-interfaces@postgresql.org
Subject: [INTERFACES] using null value timestamps


I have a problem with using a null value for a timestamp.  Here's a small
example of what I mean.

PreparedStatement pstmt =con.prepareStatement("UPDATE sometable SET date = ?");
pstmt.setTimestamp(1, null);
int rows = pstmt.executeUpdate();

Here's the exception that I'm getting.  It looks like I can't use nulls for
timestamps.

java.lang.NullPointerException       at java.util.Calendar.setTime(Calendar.java:882)       at
java.text.SimpleDateFormat.format(SimpleDateFormat.java:400)      at java.text.DateFormat.format(DateFormat.java:305)
   at
 
org.postgresql.jdbc2.PreparedStatement.setTimestamp(PreparedStatement.java:3
88)       at Test.update(Test.java:40);

We're using version 7.1.1 and the jdbc which comes with 7.0.3 and java 1.3,
redhat 7.1

Thanks,
Scott.



---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html




RE: (repost) using null value timestamps

От
"tamsin"
Дата:
i think thats a java thing - try:

PreparedStatement pstmt =    con.prepareStatement("UPDATE sometable SET date = ?");pstmt.setNull(1, 1);int rows =
pstmt.executeUpdate();

does that help?
tamsin

> -----Original Message-----
> From: pgsql-interfaces-owner@postgresql.org
> [mailto:pgsql-interfaces-owner@postgresql.org]On Behalf Of Scott Muir
> Sent: 16 August 2001 23:41
> To: pgsql-interfaces@postgresql.org
> Subject: FW: [INTERFACES] (repost) using null value timestamps
> 
> 
> anyone?
> 
> Scott.
> 
> -----Original Message-----
> From: pgsql-interfaces-owner@postgresql.org
> [mailto:pgsql-interfaces-owner@postgresql.org]On Behalf Of Scott Muir
> Sent: August 13, 2001 7:17 PM
> To: pgsql-interfaces@postgresql.org
> Subject: [INTERFACES] using null value timestamps
> 
> 
> I have a problem with using a null value for a timestamp.  Here's a small
> example of what I mean.
> 
> PreparedStatement pstmt =
>     con.prepareStatement("UPDATE sometable SET date = ?");
> pstmt.setTimestamp(1, null);
> int rows = pstmt.executeUpdate();
> 
> Here's the exception that I'm getting.  It looks like I can't use 
> nulls for
> timestamps.
> 
> java.lang.NullPointerException
>         at java.util.Calendar.setTime(Calendar.java:882)
>         at java.text.SimpleDateFormat.format(SimpleDateFormat.java:400)
>         at java.text.DateFormat.format(DateFormat.java:305)
>         at
> org.postgresql.jdbc2.PreparedStatement.setTimestamp(PreparedStatem
ent.java:3
> 88)
>         at Test.update(Test.java:40);
> 
> We're using version 7.1.1 and the jdbc which comes with 7.0.3 and 
> java 1.3,
> redhat 7.1
> 
> Thanks,
> Scott.
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
> http://www.postgresql.org/users-lounge/docs/faq.html
> 
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>