Class DbSeriesBuilder


  • public class DbSeriesBuilder
    extends java.lang.Object
    Use this to easily create Series definitions which loads data from a database. This Series performs a SQL-Query and constructs a series with the values of one row.
    Note that this builder does not validate the settings, use TaskDefinition.validate() to check for errors.

    Example usage:

     
     TaskDefinition task = new TaskDefinition("mytask");
     SeriesDefinition definition = new DbSeriesBuilder()
          .withUrl("jdbc:mysql://server:3306/databaseOne")
          .withUsername("alfred")
          .withPassword("xyz")
          .withSql("Select * from tblUser where status = 1")
          .create();
     task.setSeries( definition );
     
     // .. add jobs, actions and triggers ...
     
     TaskPlanner.getInstance().addTask( task );
     
     
     
    Since:
    taskplanner 3.0
    • Constructor Detail

      • DbSeriesBuilder

        public DbSeriesBuilder()
    • Method Detail

      • withUrl

        public DbSeriesBuilder withUrl​(@Nonnull
                                       java.lang.String url)
        Set the JDBC url to your database server.
        Example: "jdbc:mysql://server:3306/databaseOne"
        Parameters:
        url - the URl to your database
        Returns:
        this builder instance
        Throws:
        java.lang.IllegalArgumentException - if url is null or empty
        Since:
        taskplanner 3.0
      • withSql

        public DbSeriesBuilder withSql​(@Nonnull
                                       java.lang.String sql)
        Set the SQL query to use for data loading.
        Parameters:
        sql - the sql query
        Returns:
        this builder instance
        Throws:
        java.lang.IllegalArgumentException - if sql is null or empty
        Since:
        taskplanner 3.0
      • withPassword

        public DbSeriesBuilder withPassword​(@Nullable
                                            java.lang.String password)
        Set the password for the user to log in the database.
        Parameters:
        password - the password to use
        Returns:
        this builder instance
        Since:
        taskplanner 3.0
      • withUsername

        public DbSeriesBuilder withUsername​(@Nullable
                                            java.lang.String user)
        Set the username to use to log in the database.
        Parameters:
        user - the user to use
        Returns:
        this builder instance
        Since:
        taskplanner 3.0
      • create

        public SeriesDefinition create()
        Finish building and create a series definition.
        Returns:
        a definition for the database series
        Since:
        taskplanner 3.0