Class 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 Detail

      • sql

        private final String sql
      • parameterTypes

        private final int[] parameterTypes
    • Constructor Detail

      • 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 Detail

      • 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.