Class DataLoader


  • public class DataLoader
    extends java.lang.Object
    This algorithms
    reads input from input options,
    uses generator to interpret the options (generate SQL),
    executes sql and
    writes the resultSet out into the writer.
    • Method Detail

      • getOptions

        protected final IRequestOptions getOptions()
        Returns:
        the options
      • getGenerator

        protected final ISqlGenerator getGenerator()
        Returns:
        the generator
      • getDataWriter

        protected final IDataWriter getDataWriter()
        Returns:
        the dataWriter
      • isEmpty

        public boolean isEmpty()
        isEmpty
        Returns:
        true if no query was specified from the request
      • getExecuteDuration

        public final long getExecuteDuration()
        Returns:
        the sql execution executeDuration
      • getWriteDuration

        public long getWriteDuration()
        Returns:
        the writeDuration
      • getRsStartTime

        public long getRsStartTime()
        Returns:
        the rsStartTime
      • getRsEndTime

        public long getRsEndTime()
        Returns:
        the rsEndTime
      • run

        public void run()
                 throws java.lang.Exception
        run
        Throws:
        java.lang.Exception
      • prepareStatement

        protected java.sql.PreparedStatement prepareStatement​(java.sql.Connection connection,
                                                              java.lang.String sql)
                                                       throws java.lang.Exception
        Create the prepared statement Clients can overwrite this method to implement same logic
        Parameters:
        connection -
        sql -
        Returns:
        the statement
        Throws:
        java.lang.Exception
      • executeQuery

        protected java.sql.ResultSet executeQuery​(java.sql.PreparedStatement statement)
                                           throws java.lang.Exception
        Execute query generated by the generator Clients can overwrite this method to implement same logic
        Parameters:
        statement -
        Returns:
        the result set
        Throws:
        java.lang.Exception
      • writeResult

        protected void writeResult​(java.sql.ResultSet resultSet)
                            throws java.lang.Exception
        Write result out using the data writer. Clients can overwrite this method to implement same logic
        Parameters:
        resultSet - - data to write out. Can be null if generator was empty
        Throws:
        java.lang.Exception