Code example for ResultSet

Methods: getBoolean, getString

0
  public List<InputSplit> split(Configuration conf, ResultSet results, String colName)
      throws SQLException { 
 
    List<InputSplit> splits = new ArrayList<InputSplit>();
 
    if (results.getString(1) == null && results.getString(2) == null) {
      // Range is null to null. Return a null split accordingly. 
      splits.add(new DataDrivenDBInputFormat.DataDrivenDBInputSplit(
          colName + " IS NULL", colName + " IS NULL"));
      return splits;
    } 
 
    boolean minVal = results.getBoolean(1);
    boolean maxVal = results.getBoolean(2);
 
    // Use one or two splits. 
    if (!minVal) {
      splits.add(new DataDrivenDBInputFormat.DataDrivenDBInputSplit(
          colName + " = FALSE", colName + " = FALSE"));
    } 
 
    if (maxVal) {
      splits.add(new DataDrivenDBInputFormat.DataDrivenDBInputSplit(
          colName + " = TRUE", colName + " = TRUE"));
    } 
 
    if (results.getString(1) == null || results.getString(2) == null) {
      // Include a null value. 
      splits.add(new DataDrivenDBInputFormat.DataDrivenDBInputSplit(
          colName + " IS NULL", colName + " IS NULL"));
    }