UnknownTypeHandler extends BaseTypeHandler<Object> { @Override public void setNonNullParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType) throws SQLException { TypeHandler handler = resolveTypeHandler(parameter, jdbcType); handler.setParameter(ps, i, parameter, jdbcType); } UnknownTypeHandler(TypeHandlerRegistry typeHandlerRegistry); @Override void setNonNullParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType); @Override Object getNullableResult(ResultSet rs, String columnName); @Override Object getNullableResult(ResultSet rs, int columnIndex); @Override Object getNullableResult(CallableStatement cs, int columnIndex);  }
@Test public void setParameterWithNonNullParameterThrowsException() throws SQLException { doThrow(new SQLException("invalid column")).when((UnknownTypeHandler)TYPE_HANDLER).setNonNullParameter(ps, 1, 99, JdbcType.INTEGER); try { TYPE_HANDLER.setParameter(ps, 1, 99, JdbcType.INTEGER); Assert.fail("Should have thrown a TypeException"); } catch (Exception e) { Assert.assertTrue("Expected TypedException", e instanceof TypeException); Assert.assertTrue("Parameter index is in exception", e.getMessage().contains("parameter #1")); } }