From: | Artem Pronchakov <artem(dot)pronchakov(at)gmail(dot)com> |
---|---|
To: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | insert daterange field value |
Date: | 2014-03-06 08:07:21 |
Message-ID: | CANt3_r5L3+2SAGSiOe6wOiRpWumwR2fx5oASmYpyaZtLmQvPmg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Hello!
I have a table in PostgreSQL(9.3) with
daterange<http://www.postgresql.org/docs/9.3/static/rangetypes.html>
field type.
I can select this field like a String with JDBC, but I cannot Insert it in
a table.
What I've tried:
PreparedStatement stm = conn.prepareStatement("insert into mytable
(my_daterange_field) values (?)");
stm.setString(1, "[2014-01-02,2014-01-04]");int i = stm.executeUpdate();
and I got:
Exception in thread "main" org.postgresql.util.PSQLException: ERROR:
column "my_daterange_field" is of type daterange but expression is of
type character varying
Hint: You will need to rewrite or cast the expression.
Position: 168
Does anyone have a solution for inserting daterange? What stm.setXXX should
I use? Or maybe I cannot do that because JDBC Driver does not have
daterange support... Maybe there is a third solution?
Thank you.
P.S.
My PostgreSQL JDBC Driver:
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>8.4-701.jdbc4</version>
</dependency>
java <http://stackoverflow.com/questions/tagged/java>
database<http://stackoverflow.com/questions/tagged/database>
postgresql <http://stackoverflow.com/questions/tagged/postgresql>
jdbc<http://stackoverflow.com/questions/tagged/jdbc>
date-range <http://stackoverflow.com/questions/tagged/date-range>
--
Artem Pronchakov
Senior Software Developer
Gemini-Systems Russia
My PGP public key<https://keyserver2.pgp.com/vkd/DownloadKey.event?keyid=0xA60DA7F35C011396>
From | Date | Subject | |
---|---|---|---|
Next Message | Tomonari Katsumata | 2014-03-06 09:13:01 | Re: About binaryTransfer. |
Previous Message | Moran, William | 2014-03-02 17:31:01 | JDBC/TIMESTAMP/infnity question |