Repository: h2database/h2database

Issue #2175: Regression: NPE in ResultSet#getTime(int)
Created: 2019-10-15T08:31:48Z
The following Java application results in an NPE in the latest 1.4.200 version. In 1.4.199 and earlier this worked correctly:
        try (Connection c = dbSetup.getConnection()) {
            try (PreparedStatement stmt = c.prepareStatement("select current_time()")) {
                ResultSet resultSet = stmt.executeQuery();
                if (resultSet.next()) {
                    System.out.println(resultSet.getTime(1));
                }
            }
        }
Here is the stack trace:
Exception in thread "main" org.h2.jdbc.JdbcSQLNonTransientException: General error: "java.lang.NullPointerException" [50000-200]
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:505)
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:429)
	at org.h2.message.DbException.get(DbException.java:194)
	at org.h2.message.DbException.convert(DbException.java:347)
	at org.h2.message.DbException.toSQLException(DbException.java:319)
	at org.h2.message.TraceObject.logAndConvert(TraceObject.java:366)
	at org.h2.jdbc.JdbcResultSet.getTime(JdbcResultSet.java:408)
	at JDBC.main(JDBC.java:20)
Caused by: java.lang.NullPointerException
	at org.h2.value.Value.getLocalTimeNanos(Value.java:1174)
	at org.h2.value.Value.convertToTime(Value.java:1099)
	at org.h2.value.Value.convertTo(Value.java:818)
	at org.h2.value.Value.convertTo(Value.java:737)
	at org.h2.value.Value.getTime(Value.java:581)
	at org.h2.jdbc.JdbcResultSet.getTime(JdbcResultSet.java:406)
	... 1 more

Duplicate issue #2851: formatdatetime() broken for columns of type TIME in 1.4.200 
Created: 2020-08-24T21:10:54Z
This query:
select
    formatdatetime(e1_0.theTime, 'hh:mm:ss aa') 
from
    EntityOfBasics as e1_0

was working in 1.4.199, but now results in:
Caused by: org.h2.jdbc.JdbcSQLNonTransientException: General error: "java.lang.NullPointerException"; SQL statement:
select formatdatetime(e1_0.theTime, 'hh:mm:ss aa') from EntityOfBasics as e1_0 [50000-200]
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:505)
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:429)
	at org.h2.message.DbException.get(DbException.java:194)
	at org.h2.message.DbException.convert(DbException.java:347)
	at org.h2.command.Command.executeQuery(Command.java:212)
	at org.h2.jdbc.JdbcPreparedStatement.executeQuery(JdbcPreparedStatement.java:114)
	at org.hibernate.sql.results.jdbc.internal.DeferredResultSetAccess.executeQuery(DeferredResultSetAccess.java:102)
	... 80 more
Caused by: java.lang.NullPointerException
	at org.h2.value.Value.convertToTimestamp(Value.java:1146)
	at org.h2.value.Value.convertTo(Value.java:822)
	at org.h2.value.Value.convertTo(Value.java:737)
	at org.h2.value.Value.getTimestamp(Value.java:591)
	at org.h2.expression.function.Function.getValueWithArgs(Function.java:1530)
	at org.h2.expression.function.Function.getValue(Function.java:672)
	at org.h2.command.dml.Select$LazyResultQueryFlat.fetchNextRow(Select.java:1851)
	at org.h2.result.LazyResult.hasNext(LazyResult.java:101)
	at org.h2.result.LazyResult.next(LazyResult.java:60)
	at org.h2.command.dml.Select.queryFlat(Select.java:737)
	at org.h2.command.dml.Select.queryWithoutCache(Select.java:844)
	at org.h2.command.dml.Query.queryWithoutCacheLazyCheck(Query.java:201)
	at org.h2.command.dml.Query.query(Query.java:489)
	at org.h2.command.dml.Query.query(Query.java:451)
	at org.h2.command.CommandContainer.query(CommandContainer.java:285)
	at org.h2.command.Command.executeQuery(Command.java:195)
	... 82 more

Note that the problem does not seem to occur for DATE or TIMESTAMP columns.

Closing comment (2020-08-25T01:00:45Z): Duplicate of #2175