camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Karlsen <davidkarl...@gmail.com>
Subject Re: how to execte jdbc IN clause statement
Date Sun, 23 Nov 2014 17:00:17 GMT
You can still run a prepared statement - but the db-server will have to
parse and compile the different versions (one per length variant of the
list).
http://www.javaranch.com/journal/200510/Journal200510.jsp#a2

2014-11-23 17:25 GMT+01:00 Claus Ibsen <claus.ibsen@gmail.com>:

> Hi
>
> The IN is not supported. I am not sure how this would work out, as
> then you can likely not use prepared statements, but have to fallback
> to a standard SQL, and then build the query dynamic.
>
> Then the IN should be expanded, as N1, N2, N3 etc.
>
> So there is some work to do this, and also safely detect the IN, or
> that the end user need to set some option to the SQL endpoint so it
> knows its a IN and need special handling.
>
> Or am I wrong about prepared statement not supporting IN with has
> dynamic values easily?
>
> On Sun, Nov 23, 2014 at 11:03 AM, chaituu <yarlagadda54@gmail.com> wrote:
> > i have written custom prepared strategy,how to set parameter for ids' in
> > update query
> >
> >
> >
> > public class CustomPrepareStatementStrategy extends
> > org.apache.camel.component.jdbc.DefaultJdbcPrepareStatementStrategy {
> >
> >
> >
> >          private static final transient Logger LOG =
> > Logger.getLogger(CustomPrepareStatementStrategy.class);
> >
> >         @Override
> >         public Iterator<?> createPopulateIterator(String query,
> >                         String preparedQuery, int expectedParams,
> Exchange exchange,
> >                         Object value) throws SQLException {
> >
> >                 LOG.info(preparedQuery+"   preparedQuery:query:"+query);
> >                 String body =exchange.getIn().getBody(String.class);
> >                 String header= (String)exchange.getIn().getHeader("ids");
> >                 LOG.info(header+"................body:"+body);
> >
> >                   return
> > exchange.getContext().getTypeConverter().convertTo(Iterator.class,
> value);
> >
> >         }
> >
> >
> >
> > }
> >
> >
> >
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/how-to-execte-jdbc-IN-clause-statement-tp5759495p5759506.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
> hawtio: http://hawt.io/
> fabric8: http://fabric8.io/
>



-- 
--
David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message