Re: newbie question to setTimestamp( int parameterIndex, Timestamp x, Calendar cal)

From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: Peter(dot)Zoche(at)materna(dot)de
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: newbie question to setTimestamp( int parameterIndex, Timestamp x, Calendar cal)
Date: 2005-07-19 11:00:20
Message-ID: 1C7D4610-DD9B-4D42-BE3C-B2257D099D2D@fastcrypt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Peter,

Timestamp is the actual time that you want to store. The calendar
object is there if you want to use a different calendar to reference
the timestamp to ?

Dave
On 19-Jul-05, at 6:49 AM, Peter(dot)Zoche(at)materna(dot)de wrote:

> Hi all!
>
> I am new to postgresql and i have the following question:
>
> how does setTimestamp( int parameterIndex, Timestamp x, Calendar
> cal) work?
> why is there a parameter Timestamp? I have a Calendar in my java
> code and I
> would like to store it in the database via a PreparedStatement. So for
> example:
>
> I have the following table:
>
> CREATE TABLE dates( date TIMESTAMP WITH TIME ZONE );
>
> Java code:
>
> PreparedStatement ps = connection.prepareStatement( "INSERT INTO
> dates (date) VALUES ?");
> ps.setTimestamp( 1, new Timestamp(), myCalendar );
>
> Is this correct? But why is there a Timestamp parameter? It seems
> clear that
> the
> calendar should be converted into a timestamp because the method is
> named
> setTimestamp. I am really confused about this.
>
> Please help
>
> Peter
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org
>
>

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Peter.Zoche 2005-07-19 11:06:48 Re: newbie question to setTimestamp( int parameterIndex, T
Previous Message Peter.Zoche 2005-07-19 10:49:18 newbie question to setTimestamp( int parameterIndex, Timestamp x, Calendar cal)