Class DbSeriesBuilder

java.lang.Object
com.inet.taskplanner.server.api.series.DbSeriesBuilder

public class DbSeriesBuilder extends 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 Details

    • DbSeriesBuilder

      public DbSeriesBuilder()
  • Method Details

    • withUrl

      public DbSeriesBuilder withUrl(@Nonnull 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:
      IllegalArgumentException - if url is null or empty
      Since:
      taskplanner 3.0
    • withSql

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

      public DbSeriesBuilder withPassword(@Nullable 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 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