edgent-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dale LaBossiere (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (EDGENT-311) support SELECT without any parameters in JdbcStreams
Date Wed, 16 Nov 2016 17:51:58 GMT

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

Dale LaBossiere commented on EDGENT-311:
----------------------------------------

Yes, the API is designed only for PreparedStatement.  As the javadoc for ParameterSetter indicates,
the setter can set 0 or more parameters in the prepared statement.  So an empty/no-op ParameterSetter,
as you've defined for this case, is the way to go.

There doesn't seem to be sufficient value in making it easier than that to support the no-param
case, presumably by fattening the API with additional executeStatement() variants.  I suppose
the API could also allow a null ParameterSetter arg for the 0-param case, but would that really
make a meaningful difference?  Or perhaps the javadoc for ParameterSetter just needs to be
more explicit and say to declare a no-op function for the 0 param case: "(t,s)->{}"?  
Your thoughts?

Unless a compelling reason to support something other than PreparedStatement can be made,
I suspect the API won't be extended beyond that.

> 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)

Mime
View raw message