4 Replies Latest reply on Feb 4, 2017 8:14 AM by João Santana

    Dynamic sql with JbdcItemReader/JbdcItemWriter

    João Santana Newbie

      Hi all, my job changes the source table every day... how i can put the new table in sql property each execution. i trying:

      @Named
      @Dependent
      public class PigeonJdbcItemReader extends JdbcItemReader {
      
          @Inject
          @BatchProperty
          protected String prefix;
          
          @Inject
          @BatchProperty
          protected String sql;
      
          @Override
          public void open(Serializable checkpoint) throws Exception {
              DecimalFormat formater = new DecimalFormat("00");         
              String sufix = formater.format(LocalDate.now().getYear()) + "_" + formater.format(LocalDate.now().getMonthValue()) + "_" + LocalDate.now().getDayOfMonth();
              sql = sql.replaceAll("src_tbl", prefix + sufix);
              super.open(checkpoint);
          }
      }
      

       

      so... in JdbcItemReader.open the sql stay with <src_tbl> yet... and a sql error certein