pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedInserting an Interval Using JDBC
3+ messages / 2 participants
[nested] [flat]
* Inserting an Interval Using JDBC
@ 2006-01-23 17:02 Will Szopko <dba@vilaj.com>
2006-01-23 20:10 ` Re: Inserting an Interval Using JDBC Oliver Jowett <oliver@opencloud.com>
0 siblings, 1 reply; 3+ messages in thread
From: Will Szopko @ 2006-01-23 17:02 UTC (permalink / raw)
To: pgsql-jdbc
My apologies if there's a simple answer to my problem, but I've looked
and looked and can't figure it out.
I have just upgraded to the 8.1-404 version of the JDBC driver from a
much older version. In the past I had been able load an interval into my
database by sending it as a string, as such:
String myInterval = "08:00"; // 8 hour interval
...
stmt.setString(1, myInterval);
Using the new driver I am no longer able to do this and get the
following error:
column "num_hours" is of type interval but expression is of type text
I have looked through the driver source code, but don't see that I could
send the value as an "object" or as one of the other time-related types.
If someone might be able to point me to a solution to this problem, I'd
be most appreciative.
Thanks.
- Will
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Inserting an Interval Using JDBC
2006-01-23 17:02 Inserting an Interval Using JDBC Will Szopko <dba@vilaj.com>
@ 2006-01-23 20:10 ` Oliver Jowett <oliver@opencloud.com>
2006-01-23 20:19 ` Re: Inserting an Interval Using JDBC Will Szopko <dba@vilaj.com>
0 siblings, 1 reply; 3+ messages in thread
From: Oliver Jowett @ 2006-01-23 20:10 UTC (permalink / raw)
To: dba@vilaj.com; +Cc: pgsql-jdbc
Will Szopko wrote:
> I have just upgraded to the 8.1-404 version of the JDBC driver from a
> much older version. In the past I had been able load an interval into my
> database by sending it as a string, as such:
>
> String myInterval = "08:00"; // 8 hour interval
> ...
> stmt.setString(1, myInterval);
>
> Using the new driver I am no longer able to do this and get the
> following error:
>
> column "num_hours" is of type interval but expression is of type text
Use "CAST (? AS INTERVAL)" in your query, or use the custom
org.postgresql.util.PGInterval type and pass an instance to setObject().
-O
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Inserting an Interval Using JDBC
2006-01-23 17:02 Inserting an Interval Using JDBC Will Szopko <dba@vilaj.com>
2006-01-23 20:10 ` Re: Inserting an Interval Using JDBC Oliver Jowett <oliver@opencloud.com>
@ 2006-01-23 20:19 ` Will Szopko <dba@vilaj.com>
0 siblings, 0 replies; 3+ messages in thread
From: Will Szopko @ 2006-01-23 20:19 UTC (permalink / raw)
To: Oliver Jowett <oliver@opencloud.com>; pgsql-jdbc
Oliver -
Thanks, much! I figured the latter out subsequent to my initial post,
but had not thought of the former, which ended up being more elegant for
my application. Again, thanks.
- Will
Oliver Jowett wrote:
> Will Szopko wrote:
>
>> I have just upgraded to the 8.1-404 version of the JDBC driver from a
>> much older version. In the past I had been able load an interval into
>> my database by sending it as a string, as such:
>>
>> String myInterval = "08:00"; // 8 hour interval
>> ...
>> stmt.setString(1, myInterval);
>>
>> Using the new driver I am no longer able to do this and get the
>> following error:
>>
>> column "num_hours" is of type interval but expression is of type text
>
> Use "CAST (? AS INTERVAL)" in your query, or use the custom
> org.postgresql.util.PGInterval type and pass an instance to setObject().
>
> -O
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2006-01-23 20:19 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-01-23 17:02 Inserting an Interval Using JDBC Will Szopko <dba@vilaj.com>
2006-01-23 20:10 ` Oliver Jowett <oliver@opencloud.com>
2006-01-23 20:19 ` Will Szopko <dba@vilaj.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox