Re: Strange behaviour of rs.getTimestamp

Поиск
Список
Период
Сортировка
От Kevin Grittner
Тема Re: Strange behaviour of rs.getTimestamp
Дата
Msg-id 4D2583B20200002500039059@gw.wicourts.gov
обсуждение исходный текст
Ответ на Re: Strange behaviour of rs.getTimestamp  (Altaf Malik <mmalik_altaf@yahoo.com>)
Ответы Re: Strange behaviour of rs.getTimestamp
Список pgsql-jdbc
Altaf Malik <mmalik_altaf@yahoo.com> wrote:

>> So, what's different between the ones that yield the correct
>> values and the ones that don't?
>
> Please look at the values:
> 2009-04-15 00:00:00->2009-04-15 01:00:00.0

You didn't read very closely -- you said some machines gave the
right answer and some the wrong answer.  Clearly there's something
different from one to the other.  What?

>> If you can put together a self-contained test case that someone
>> can compile and run on their own machine, it becomes much easier
>> for others to understand the problem and to help.
>
> I did so. Please read the following portion carefully:

No, that was a code snippet.  I fleshed it out to a compilable
source file like this:

import java.sql.*;
public final class TestTS
{
    public static void main(String[] args) throws Exception
    {
        Class.forName("org.postgresql.Driver");
        Connection con = DriverManager.getConnection
            ("jdbc:postgresql:test", "test", "test");
        Statement stmt = con.createStatement();
        stmt.executeUpdate("create table ts_test(a timestamp)");
        stmt.executeUpdate
            ("insert into ts_test values('15-APR-09');");
        ResultSet rs = stmt.executeQuery("select * from  ts_test");
        System.out.println(System.getProperty("java.vendor"));
        System.out.println(System.getProperty("java.version"));
        System.out.println(System.getProperty("java.vm.name"));
        System.out.println(System.getProperty("java.vm.info"));
        while (rs.next()) {
            Timestamp t = rs.getTimestamp(1);
            System.out.println(rs.getString(1)+"->"+ t);
        }
        rs.close();
        stmt.executeUpdate("drop table ts_test");
        stmt.close();
        con.close();
    }
}

When I compile and run, I get this:

Sun Microsystems Inc.
1.6.0_21
Java HotSpot(TM) Client VM
mixed mode, sharing
2009-04-15 00:00:00->2009-04-15 00:00:00.0

Unless you provide more information, nobody can help.

-Kevin

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

Предыдущее
От: Altaf Malik
Дата:
Сообщение: Re: Strange behaviour of rs.getTimestamp
Следующее
От: shubhadeep chattopadhyay
Дата:
Сообщение: port problem