/** * {@inheritDoc} */ @Override public void set(final PreparedStatement st, final int index, final Time value, final int dbSqlType) throws SQLException { st.setTime(index, value); }
@Override public void setTime(int parameterIndex, Time x) throws SQLException { rawStatement.setTime(parameterIndex, x); }
@Override public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException { rawStatement.setTime(parameterIndex, x, cal); }
@Override public final void setTime(final int parameterIndex, final Time x) throws SQLException { getTargetPreparedStatement().setTime(parameterIndex, x); }
@Override public final void setTime(final int parameterIndex, final Time x, final Calendar cal) throws SQLException { getTargetPreparedStatement().setTime(parameterIndex, x, cal); }
@Override public void setTime(int parameterIndex, Time x) throws SQLException { setParamByIndex(parameterIndex, x); targetStatement.setTime(parameterIndex, x); }
@Override public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException { setParamByIndex(parameterIndex, x); targetStatement.setTime(parameterIndex, x, cal); }
@Override public void set(PreparedStatement prep, int parameterIndex) throws SQLException { prep.setTime(parameterIndex, getTime()); }
@Override protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { final Time time = javaTypeDescriptor.unwrap( value, Time.class, options ); if ( value instanceof Calendar ) { st.setTime( index, time, (Calendar) value ); } else if (options.getJdbcTimeZone() != null) { st.setTime( index, time, Calendar.getInstance( options.getJdbcTimeZone() ) ); } else { st.setTime( index, time ); } }
@Override public void setTime(int parameterIndex, Time x) throws SQLException { checkOpen(); try { stmt.setTime(parameterIndex, x); } catch (Throwable t) { throw checkException(t); } }
@Override public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException { checkOpen(); try { stmt.setTime(parameterIndex, x, cal); } catch (Throwable t) { throw checkException(t); } }
@Override public void preparedStatement_setTime(PreparedStatementProxy statement, int parameterIndex, java.sql.Time x, Calendar cal) throws SQLException { if (this.pos < filterSize) { nextFilter().preparedStatement_setTime(this, statement, parameterIndex, x, cal); return; } statement.getRawObject().setTime(parameterIndex, x, cal); }
@Override public void preparedStatement_setTime(PreparedStatementProxy statement, int parameterIndex, java.sql.Time x) throws SQLException { if (this.pos < filterSize) { nextFilter().preparedStatement_setTime(this, statement, parameterIndex, x); return; } statement.getRawObject().setTime(parameterIndex, x); }
@Test public void testSetParameterValueWithTimeAndCalendar() throws SQLException { java.util.Calendar cal = new GregorianCalendar(); StatementCreatorUtils.setParameterValue(preparedStatement, 1, Types.TIME, null, cal); verify(preparedStatement).setTime(1, new java.sql.Time(cal.getTime().getTime()), cal); }
@Test public void testSetParameterValueWithTimeAndUtilDate() throws SQLException { java.util.Date date = new java.util.Date(1000); StatementCreatorUtils.setParameterValue(preparedStatement, 1, Types.TIME, null, date); verify(preparedStatement).setTime(1, new java.sql.Time(1000)); }
public Q setTime(final int index, final Time value) { initPrepared(); try { preparedStatement.setTime(index, value); } catch (SQLException sex) { throwSetParamError(index, sex); } return _this(); }
@Test public void testSetParameterValueWithSqlTime() throws SQLException { java.sql.Time time = new java.sql.Time(1000); StatementCreatorUtils.setParameterValue(preparedStatement, 1, Types.TIME, null, time); verify(preparedStatement).setTime(1, time); }
public Q setTime(final String param, final Time value) { initPrepared(); final int[] positions = query.getNamedParameterIndices(param); try { for (final int position : positions) { preparedStatement.setTime(position, value); } } catch (SQLException sex) { throwSetParamError(param, sex); } return _this(); }
@Test public void testConvertTime() throws SQLException { LocalTime time = LocalTime.of(12, 34, 56); Time sqlTime = Time.valueOf(time); java.util.Date javaDate = new java.util.Date(sqlTime.getTime()); LocalDateTime dateTime = LocalDateTime.of(LocalDate.of(2001, 5, 6), time); Timestamp sqlTimestamp = Timestamp.valueOf(dateTime); assertParameter(sqlTime, Types.TIME, (ps, i) -> ps.setTime(i, sqlTime)); assertParameter(sqlTime, Types.TIME, (ps, i) -> ps.setObject(i, sqlTime)); assertParameter(sqlTime, Types.TIME, (ps, i) -> ps.setObject(i, sqlTime, Types.TIME)); assertParameter(sqlTime, Types.TIME, (ps, i) -> ps.setObject(i, sqlTimestamp, Types.TIME)); assertParameter(sqlTime, Types.TIME, (ps, i) -> ps.setObject(i, javaDate, Types.TIME)); assertParameter(sqlTime, Types.TIME, (ps, i) -> ps.setObject(i, dateTime, Types.TIME)); assertParameter(sqlTime, Types.TIME, (ps, i) -> ps.setObject(i, "12:34:56", Types.TIME)); }
@ParameterizedTest @CsvSource(value = {"21:44:06, 92"}) void call_setTime(@ConvertWith(ToSqlTimeArgumentConverter.class) Time value, int targetSqlType) throws SQLException { DbUtil.setPreparedStatementObject(mock, index, value, targetSqlType); Mockito.verify(mock, Mockito.times(1)).setTime(index, value); }