Class AnnotationBatcher.InsertBatcher

java.lang.Object
net.sf.basedb.core.AnnotationBatcher.InsertBatcher
Enclosing class:
AnnotationBatcher

static class AnnotationBatcher.InsertBatcher
extends Object
Batcher implementation for inserting into tables. Assumes that the table has an "id" column that is auto-generated by the SQL statement. The value of the generated id is retuned by the insert(Object[]) method.
  • Field Details

    • sql

      private final String sql
    • statement

      private final PreparedStatement statement
    • parameterTypes

      private final int[] parameterTypes
  • Constructor Details

    • InsertBatcher

      InsertBatcher​(Connection c, String sql, int... parameterTypes) throws SQLException
      Prepare a new batcher for the given SQL statement.
      Parameters:
      sql - A SQL statement
      parameterTypes - Parameter type codes as defined in Types.
      Throws:
      SQLException
  • Method Details

    • getSql

      String getSql()
      The SQL statement this batcher is executing.
    • insert

      int insert​(Object... values) throws SQLException
      Execute an insert SQL statement with the given parameter values. The number of values must match the number of parameter types.
      Returns:
      The ID of inserted row
      Throws:
      SQLException
    • close

      void close()
      Close the batcher.