gquintana <gerald.quint...@gmail.com> writes: > From documentation, Derby is supposed to implement JDBC4.2 which introduces > JSR 310 (Date & Time API) support into JDBC (among other things). > > Reading http://openjdk.java.net/jeps/170, I would have thought the following > code would work, but it doesn't: > > LocalDate birthDate = .... > statement.setObject(5, birthDate, Types.DATE); > > Caused by: ERROR XCL12: Une tentative de placement d'une valeur de données de > type 'java.time.LocalDate' dans une valeur de données de type 'DATE' a été > effectuée. > at org.apache.derby.client.am.CrossConverters.setObject(Unknown Source) > at > org.apache.derby.client.am.ClientPreparedStatement.setObjectX(Unknown Source) > ... 52 more > > > LocalDate birthDate=resultSet.getObject("birth_date", LocalDate.class); > > Caused by: ERROR 22005: Une tentative d'obtention d'une valeur de données de > type 'java.time.LocalDate' à partir d'une valeur de données de type 'DATE' a > été effectuée. > ... 66 more > > > > What's the supposed way of reading/writing JSR 310 types from/into JDBC > database?
Derby doesn't support the new type mappings yet. There is a JIRA issue that tracks it (https://issues.apache.org/jira/browse/DERBY-6445), but there hasn't been any activity yet. For now, you'll have to convert JSR 310 time and date values to the corresponding classes in the java.sql package yourself. For example: statement.setDate(5, java.sql.Date.valueOf(birthDate)); ... LocalDate birthDate = resultSet.getDate("birth_date").toLocalDate(); Hope this helps, -- Knut Anders