pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedInserting Information in PostgreSQL interval
3+ messages / 2 participants
[nested] [flat]
* Inserting Information in PostgreSQL interval
@ 2009-06-21 22:14 BlackMage <dsd7872@uncw.edu>
0 siblings, 2 replies; 3+ messages in thread
From: BlackMage @ 2009-06-21 22:14 UTC (permalink / raw)
To: pgsql-jdbc
Hey,
I am having trouble entering intervals into a PostgreSQL inverval field.
Currently I using prepared statements that look like this:
{code}
PreparedStatement query = conn.prepareStatement("INSERT............");
query.setObject(1, "{28.1, 29.2}");
query.setObject(2, "{1:23, 1:24}");
query.execute();
{code}
And when I execute the code I get this error:
org.postgresql.util.PSQLException: ERROR: column "field_1" is of type
interval[] but expression is of type character varying
So is there another way of entering an array of intervals into a postgresql
database using prepared statement? What am I doing wrong?
--
View this message in context: http://www.nabble.com/Inserting-Information-in-PostgreSQL-interval-tp24139349p24139349.html
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Inserting Information in PostgreSQL interval
@ 2009-06-22 00:11 Oliver Jowett <oliver@opencloud.com>
parent: BlackMage <dsd7872@uncw.edu>
1 sibling, 0 replies; 3+ messages in thread
From: Oliver Jowett @ 2009-06-22 00:11 UTC (permalink / raw)
To: BlackMage <dsd7872@uncw.edu>; +Cc: pgsql-jdbc
BlackMage wrote:
> query.setObject(1, "{28.1, 29.2}");
> org.postgresql.util.PSQLException: ERROR: column "field_1" is of type
> interval[] but expression is of type character varying
The two-argument form of setObject() infers a type of Types.VARCHAR for
a java.lang.String (see the JDBC spec)
> So is there another way of entering an array of intervals into a postgresql
> database using prepared statement? What am I doing wrong?
Try:
query.setObject(1, "{28.1, 29.2}", Types.OTHER);
-O
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Inserting Information in PostgreSQL interval
@ 2009-06-22 00:27 BlackMage <dsd7872@uncw.edu>
parent: BlackMage <dsd7872@uncw.edu>
1 sibling, 0 replies; 3+ messages in thread
From: BlackMage @ 2009-06-22 00:27 UTC (permalink / raw)
To: pgsql-jdbc
Hey, that worked!
Thanks a lot.
BlackMage wrote:
>
> Hey,
>
> I am having trouble entering intervals into a PostgreSQL inverval field.
> Currently I using prepared statements that look like this:
>
> {code}
>
> PreparedStatement query = conn.prepareStatement("INSERT............");
> query.setObject(1, "{28.1, 29.2}");
> query.setObject(2, "{1:23, 1:24}");
> query.execute();
> {code}
>
> And when I execute the code I get this error:
>
> org.postgresql.util.PSQLException: ERROR: column "field_1" is of type
> interval[] but expression is of type character varying
>
>
> So is there another way of entering an array of intervals into a
> postgresql database using prepared statement? What am I doing wrong?
>
>
--
View this message in context: http://www.nabble.com/Inserting-Information-in-PostgreSQL-interval-tp24139349p24140292.html
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2009-06-22 00:27 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2009-06-21 22:14 Inserting Information in PostgreSQL interval BlackMage <dsd7872@uncw.edu>
2009-06-22 00:11 ` Oliver Jowett <oliver@opencloud.com>
2009-06-22 00:27 ` BlackMage <dsd7872@uncw.edu>
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