On Thu, Mar 6, 2014 at 4:27 PM, Sehrope Sarkuni <sehrope@jackdb.com> wrote:
> 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?
You need to specify the cast in your SQL and then bind the parameter with setObject(...).
String value = "[2014-01-02,2014-01-04]"; String sql = "INSERT INTO date_range_test (some_field) VALUES (?::daterange)"; PreparedStatement stmt = conn.prepareStatement(sql); stmt.setObject(1, value); stmt.execute();