edgent-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rui Shen (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (EDGENT-311) support SELECT without any parameters in JdbcStreams
Date Fri, 18 Nov 2016 03:56:58 GMT

    [ https://issues.apache.org/jira/browse/EDGENT-311?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15675658#comment-15675658

Rui Shen commented on EDGENT-311:

The key thing here is not ParameterSetter, but the first parameter TStream in db.executeStatement
method. My understanding is that this stream provides the needed SQL parameters, but if there
is no parameters (i.e. no "?") in my SELECT statement, the stream parameter is supposed to
be set to return nothing. But the current result is that if the stream parameter returns nothing,
you won't see the SQL is executed. You could give a try. So that's why I put a "dummy" in
the stream parameter,which's purpose is just to trigger the SQL execution, but doesn't it
look weird? :). 

> 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

View raw message