[
https://issues.apache.org/jira/browse/EDGENT-311?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15683675#comment-15683675
]
Dale LaBossiere commented on EDGENT-311:
----------------------------------------
Ah. The basic model the connector's API presents is "Each tuple on the input
streams triggers the execution of the prepared statement, generating 0 or more
tuples on the result stream. It's very general. The tuple's contents may or
may not supply values for statement parameters. The tuple many or may not be
present in the result stream -- e.g., enrichment vs simple query results."
Interpreting the input tuple only as "the parameters of the prepared statement"
is a bit too constraining. And it's not correct to think of the
ParameterSetter as returning anything or triggering statement execution - the
setter is just called to set any parameters in the prepared statement it's
given.
Viewed in this light, does the API make more sense to you?
Do you image this "one-time statement execution" case you've described to be a
common one? Maybe you could elaborate on the use case, give some more context,
so as to make an argument for why the API should be augmented in order to
simplify implementing this use case.
> support SELECT without any parameters in JdbcStreams
> ----------------------------------------------------
>
> Key: EDGENT-311
> URL: https://issues.apache.org/jira/browse/EDGENT-311
> Project: Edgent
> Issue Type: Improvement
> Components: Connectors
> Affects Versions: Apache Edgent 1.0.0
> Reporter: Rui Shen
> Priority: Minor
>
> 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);
>
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)