Class BatchStatement


  • public class BatchStatement
    extends java.lang.Object
    This class is used for managing prepared statements when using batching (or optionally using batching). If a batch size is set (not 0), operations will be executed in batches. Otherwise the will be executed normally. Special care is taken not to execute empty batches, as that throws an error in Java.
    • Constructor Summary

      Constructors 
      Constructor Description
      BatchStatement​(java.sql.PreparedStatement ps)  
      BatchStatement​(java.sql.PreparedStatement ps, int batchSize)
      If batch limit is 0, won't use batching.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      void execute()
      Calls addBatch() if using batching, execute() otherwise.
      void finish()
      Executes the remaining batch.
      int getCount()  
      java.sql.PreparedStatement getStatement()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BatchStatement

        public BatchStatement​(java.sql.PreparedStatement ps)
      • BatchStatement

        public BatchStatement​(java.sql.PreparedStatement ps,
                              int batchSize)
        If batch limit is 0, won't use batching.
    • Method Detail

      • getCount

        public int getCount()
      • execute

        public void execute()
                     throws java.sql.SQLException
        Calls addBatch() if using batching, execute() otherwise.
        Throws:
        java.sql.SQLException
      • finish

        public void finish()
                    throws java.sql.SQLException
        Executes the remaining batch. If not using batching, does nothing.
        Throws:
        java.sql.SQLException
      • getStatement

        public java.sql.PreparedStatement getStatement()
      • close

        public void close()