Thread: Timestamp

Timestamp

From
"Alex Falkowski"
Date:
I read your latest java/JDBC news and i saw that you fixed the timestamp problem, yet when i install the new jar files an run this code
 
DataSource d = (DataSource) new InitialContext().lookup("java:comp/env/jdbc/macquarie_awards");
 
 java.sql.Connection conn = d.getConnection();
 
 out.println(conn.getMetaData().getDriverVersion() + "<BR>");
        java.sql.PreparedStatement pstmt;
        pstmt = conn.prepareStatement("SELECT o.id FROM question o WHERE (o.question_date = ?)");
        pstmt.setTimestamp(1, new java.sql.Timestamp(1024668000000L));
       
        out.println(new java.sql.Timestamp(1024668000000L) + "<BR>");
        out.println(pstmt + "<BR>");
 
I get the following output, which clearly marks to me that setTimestamp is doing something wrong
 
PostgreSQL 7.2 JDBC2
2002-06-22 00:00:00.0
SELECT o.id FROM question o WHERE (o.question_date = '2002-06-21 14:00:00.00+00')
 
Is this being fixed, cause my EJB are not returning the right values cause of this

Re: Timestamp

From
Dave Cramer
Date:
You may want to try the dev driver. Any modifications between releases
will be built into that jar, as opposed to the release jar

Dave
On Sun, 2002-06-23 at 21:09, Alex Falkowski wrote:
> I read your latest java/JDBC news and i saw that you fixed the timestamp problem, yet when i install the new jar
filesan run this code 
>
> DataSource d = (DataSource) new InitialContext().lookup("java:comp/env/jdbc/macquarie_awards");
>
>  java.sql.Connection conn = d.getConnection();
>
>  out.println(conn.getMetaData().getDriverVersion() + "<BR>");
>         java.sql.PreparedStatement pstmt;
>         pstmt = conn.prepareStatement("SELECT o.id FROM question o WHERE (o.question_date = ?)");
>         pstmt.setTimestamp(1, new java.sql.Timestamp(1024668000000L));
>
>         out.println(new java.sql.Timestamp(1024668000000L) + "<BR>");
>         out.println(pstmt + "<BR>");
>
> I get the following output, which clearly marks to me that setTimestamp is doing something wrong
>
> PostgreSQL 7.2 JDBC2
> 2002-06-22 00:00:00.0
> SELECT o.id FROM question o WHERE (o.question_date = '2002-06-21 14:00:00.00+00')
>
> Is this being fixed, cause my EJB are not returning the right values cause of this
>






Re: Timestamp

From
Tom Lane
Date:
"Alex Falkowski" <alex@l-o-u-d.com> writes:
> I get the following output, which clearly marks to me that setTimestamp is =
> doing something wrong

> PostgreSQL 7.2 JDBC2
> 2002-06-22 00:00:00.0
> SELECT o.id FROM question o WHERE (o.question_date =3D '2002-06-21 14:00:00=
> .00+00')

It's not apparent to me that this is wrong --- is the second println
reporting the Timestamp's value in your local timezone?  I guess that
your local timezone is GMT+10 from your Date: header, in which case
the two values are perfectly consistent.

            regards, tom lane



Re: Timestamp

From
Barry Lind
Date:
Alex,

I don't see anything wrong in what you have shown here.  You must
understand that Timestamp.toString()  prints out the timestamp in the
local timezone.  You will see that the PreparedStatement is using the
GMT timezone (i.e. +00).  Thus these two are identical (assuming your
local timezone is GMT-10).

thanks,
--Barry

Alex Falkowski wrote:

> I read your latest java/JDBC news and i saw that you fixed the
> timestamp problem, yet when i install the new jar files an run this code
>
> DataSource d = (DataSource) new
> InitialContext().lookup("java:comp/env/jdbc/macquarie_awards");
>
>  java.sql.Connection conn = d.getConnection();
>
>  out.println(conn.getMetaData().getDriverVersion() + "<BR>");
>         java.sql.PreparedStatement pstmt;
>         pstmt = conn.prepareStatement("SELECT o.id FROM question o
> WHERE (o.question_date = ?)");
>         pstmt.setTimestamp(1, new java.sql.Timestamp(1024668000000L));
>
>         out.println(new java.sql.Timestamp(1024668000000L) + "<BR>");
>         out.println(pstmt + "<BR>");
>
> I get the following output, which clearly marks to me that
> setTimestamp is doing something wrong
>
> PostgreSQL 7.2 JDBC2
> 2002-06-22 00:00:00.0
> SELECT o.id FROM question o WHERE (o.question_date = '2002-06-21
> 14:00:00.00+00')
>
> Is this being fixed, cause my EJB are not returning the right values
> cause of this