Hi,
I am using DERBY: "10.10.1.2", packaged with Java 8 JDK
("java.runtime.version=1.8.0-ea-b120").
I created a table in-memory: create table Persoon (id int not null
GENERATED ALWAYS AS IDENTITY , datum date not null, tijd time not null,
tijdstip timestamp not null)
When I use the following code:
try (PreparedStatement preparedStatement =
connection.prepareStatement("insert into Persoon (datum, tijd, tijdstip)
values (?,?,?)")) {
preparedStatement.setObject(1, LocalDate.of(2014, 3, 20),
JDBCType.DATE);
I get the following exception:
java.sql.SQLDataException: An attempt was made to get a data value of type
'DATE' from a data value of type 'java.time.LocalDate'.
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown
Source)
at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.newSQLException(Unknown
Source)
at org.apache.derby.impl.jdbc.ConnectionChild.newSQLException(Unknown
Source)
at
org.apache.derby.impl.jdbc.EmbedPreparedStatement.dataTypeConversion(Unknown
Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.setObject(Unknown
Source)
at
nl.ordina.jdk8.TimePersistenceTest.insertParameterSetObject(TimePersistenceTest.java:48)
If I skip the JDBCType.Date, I get the same error.
In the "JDBC Maintenance Release 4.2" proposed changes the following is
written
"21 Add the following mapping to table B-4, Mapping from Java Objects to
JDBC Types
• Map the Java Object Type javax.time.LocalDate to the JDBC Type DATE
22 Add the following mapping to table B-5, Mapping, conversions Performed
by setObject and setNull between
Java Object Types
• Allow the conversion of javax.time.LocalDate to CHAR, VARCHAR,
LONGVARCHAR, and DATE"
Am I missing something?
Regards,
Martijn Blankestijn