Thread: JDBC and intervals

JDBC and intervals

From
Pablo Velasquez Rivas
Date:
Hi.

I'm trying to get an interval from a postgresql query.

I was using jdbc for postgresql 7.3.x, and my query was:

ResultSet.executeQuery("SELECT (final_date - initial_date) FROM some_table") ;

When I did something like this:
System.out.println(resultSet.getObject(1)),  , I got the message: " Error = No class found for interval"

So, I tried upgrating to postgresql 7.4.x, and if I do
System.out.println(resultSet.getObject(1)) ,  I get : null.

So, is there a way to get an interval from a postgresql query ?, or am I doing something wrong ??


Thanks for any help.
==                                 ==
   Pablo A. Velasquez Rivas
Computer Science Engineer
==                                 ==

Re: JDBC and intervals

From
Dave Cramer
Date:
Pablo,


OK, I played with this a bit, you can do a cast of final - initial as a
time which the driver s/b able to deal with

davec=# select (final - initial)::time as x from intvl1;
    x
----------
 00:00:00
(1 row)

also naming it would be helpful, but this does sound like a driver bug.

Dave

On Mon, 2004-02-09 at 16:11, Pablo Velasquez Rivas wrote:
> Hi.
>
> I'm trying to get an interval from a postgresql query.
>
> I was using jdbc for postgresql 7.3.x, and my query was:
>
> ResultSet.executeQuery("SELECT (final_date - initial_date) FROM
> some_table") ;
>
> When I did something like this:
> System.out.println(resultSet.getObject(1)),  , I got the message: "
> Error = No class found for interval"
>
> So, I tried upgrating to postgresql 7.4.x, and if I do
> System.out.println(resultSet.getObject(1)) ,  I get : null.
>
> So, is there a way to get an interval from a postgresql query ?, or am
> I doing something wrong ??
>
>
> Thanks for any help.
> ==                                 ==
>    Pablo A. Velasquez Rivas
> Computer Science Engineer
> ==                                 ==
--
Dave Cramer
519 939 0336
ICQ # 14675561


Re: JDBC and intervals

From
Pablo Velasquez Rivas
Date:
Thanks for the help. It worked.

But, just a little question.

Well, how I'm dealing with dates, so maybe the difference between some days would be greater than the latest representation in a time type.

For example,

    interval           |  time
1 day 02 : 15       |  02:15
2 days 00:02        | 00:02
 and so on.


So, is there a way to get that kind of intervals (greater than one day) ?

Thanks.
--
==                                 ==
   Pablo A. Velasquez Rivas
Computer Science Engineer
==                                 ==