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

Поиск
Список
Период
Сортировка
От Peter.Zoche@materna.de
Тема newbie question to setTimestamp( int parameterIndex, Timestamp x, Calendar cal)
Дата
Msg-id 3617A3C21370D045B75C0A40A7A6530D0B37E17E@ntexc2buc.do-office.buc.materna.com
обсуждение исходный текст
Ответы Re: newbie question to setTimestamp( int parameterIndex, Timestamp x, Calendar cal)  (Dave Cramer <pg@fastcrypt.com>)
Список pgsql-jdbc
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

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

Предыдущее
От: im i
Дата:
Сообщение: Re: org.postgresql.util.PSQLException: ERROR: current transaction is aborted, commands ignored until end of transaction block
Следующее
От: Dave Cramer
Дата:
Сообщение: Re: newbie question to setTimestamp( int parameterIndex, Timestamp x, Calendar cal)