Class SqlTimestampGenerator

java.lang.Object
io.bloviate.gen.AbstractDataGenerator<Timestamp>
io.bloviate.gen.SqlTimestampGenerator
All Implemented Interfaces:
DataGenerator<Timestamp>

public class SqlTimestampGenerator extends AbstractDataGenerator<Timestamp>
Generates random Timestamp values for binding to JDBC TIMESTAMP columns, drawn uniformly from a millisecond instant in the half-open range [start, end) (start inclusive, end exclusive). By default the range is centered on AbstractBuilder.DEFAULT_REFERENCE, spanning from 100 days before it up to (but excluding) 100 days after it. Backed by the builder's seeded RandomGenerator, so the same seed yields identical output.
  • Method Details

    • generate

      public Timestamp generate()
      Description copied from interface: DataGenerator
      Generates a random value of type T.
      Returns:
      a generated value, may be null if the generator supports nullable columns
    • set

      public void set(Connection connection, PreparedStatement statement, int parameterIndex, Timestamp value) throws SQLException
      Description copied from interface: DataGenerator
      Sets a specific value on a PreparedStatement parameter.
      Specified by:
      set in interface DataGenerator<Timestamp>
      Overrides:
      set in class AbstractDataGenerator<Timestamp>
      Parameters:
      connection - the database connection
      statement - the prepared statement to set the parameter on
      parameterIndex - the 1-based parameter index
      value - the value to set
      Throws:
      SQLException - if the database operation fails
    • get

      public Timestamp get(ResultSet resultSet, int columnIndex) throws SQLException
      Description copied from interface: DataGenerator
      Retrieves a value from a ResultSet column.
      Parameters:
      resultSet - the result set to read from
      columnIndex - the 1-based column index
      Returns:
      the value from the result set, properly cast to type T
      Throws:
      SQLException - if the database operation fails