java - Insert "daterange" field value into PostgreSQL table through JDBC -
i have table in postgresql(9.3) daterange field type.
i can select field string jdbc, cannot insert in table.
what i've tried:
preparedstatement stm = conn.preparestatement("insert mytable (my_daterange_field) values (?)"); stm.setstring(1, "[2014-01-02,2014-01-04]"); int = stm.executeupdate();
and got:
exception in thread "main" org.postgresql.util.psqlexception: error: column "my_daterange_field" of type daterange expression of type character varying hint: need rewrite or cast expression. position: 168
does have solution inserting daterange? stm.setxxx should use? or maybe cannot because jdbc driver not have daterange support... maybe there third solution?
thank you.
p.s.
my postgresql jdbc driver:
<dependency> <groupid>postgresql</groupid> <artifactid>postgresql</artifactid> <version>8.4-701.jdbc4</version> </dependency>
use:
insert mytable (my_daterange_field) values (?::daterange)
Comments
Post a Comment