Uploaded image for project: 'Edgent'
  1. Edgent
  2. EDGENT-311

support SELECT without any parameters in JdbcStreams

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Not A Problem
    • Apache Edgent 1.0.0
    • None
    • Connectors
    • None

    Description

      Now I am trying to run a SELECT statement without parameters (e.g "select id,name,age from person") using JdbcStreams. But I found there is no straightforward way to do this. Looks like the APIs of JdbcStreams is designed for only prepared statement with parameters .
      However, I found a workaround to make this - always create a TStream with one tuple but in the ParameterSetter, does nothing. Although this works, it looks uncomfortable. Are you going to support this in the future release?

      Topology t = this.newTopology("testSelect_WithParameters");
      JdbcStreams db=new JdbcStreams(ds,(ds)=>

      {ds.getConnection()}

      );
      TStream<String> stream=t.collection(Arrays.asList(new String[]

      {"dummy"}

      )); // to execute the sql, always needs to create a TStream containing one tuple.
      ParameterSetter<String> paramSetter=(s,stmt)->{}; //do nothing here
      ResultsHandler<Object[], JsonObject> rh = (tuple, rs, exc, consumer) -> {};
      db.executeStatement(stream, "select id,name,age from person", paramSetter,rh);

      Attachments

        Activity

          People

            Unassigned Unassigned
            ilovepumpkin Rui Shen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: