I have JDBC code that is inserted into a database table by doing PreparedStatement. When I run the code in the HSQLDB database in memory (as part of the JUnit test), I get an SQLFeatureNotSupportedException exception, the only information is the message "function not supported" and the vendor code is -1500. What I am doing is a basic insertion into a table - I cannot imagine that this is not supported in the latest HSQLDB.
My code is:
public Observations saveOrUpdate(final Observations observations) { try { if (connection == null) { connection = getJdbcTemplate().getDataSource().getConnection(); } // create the prepared statement String sql = "INSERT INTO " + Observations.TABLE_NAME + " (OBS_YEAR, WINTER, SPRING, SUMMER, FALL, ANNUAL, DATA_TYPE, CREATED_DATE, UPDATED_DATE, " + Observations.ID_COLUMN_NAME + ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; PreparedStatement preparedStatement = connection.prepareStatement(sql); preparedStatement.setInt(1, observations.getYear()); preparedStatement.setBigDecimal(2, observations.getJan()); preparedStatement.setBigDecimal(3, observations.getFeb()); preparedStatement.setBigDecimal(4, observations.getMar()); preparedStatement.setBigDecimal(5, observations.getApr()); preparedStatement.setBigDecimal(6, observations.getMay()); preparedStatement.setString(7, observations.getDataType().toString()); preparedStatement.setTimestamp(8, new Timestamp(observations.getCreatedDate().getTime())); preparedStatement.setTimestamp(9, new Timestamp(observations.getUpdatedDate().getTime())); preparedStatement.setLong(10, observations.getId()); preparedStatement.executeUpdate(sql); return observations; } catch (SQLException ex) { throw new RuntimeException(ex); } }
Can anyone suggest what could be the problem or something else that I should investigate further? Thanks in advance for your help.
- james
java sql exception jdbc hsqldb
James adams
source share