Home > Archive > PostgreSQL JDBC > July 2005 > newbie question to setTimestamp( int parameterIndex, Timestamp x,









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author newbie question to setTimestamp( int parameterIndex, Timestamp x,
Peter.Zoche@materna.de

2005-07-19, 7:24 am

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

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com