Results 1 to 2 of 2

Thread: SpringJDBC Select Query In Clause More than 500

  1. #1
    Join Date
    Sep 2008
    Posts
    3

    Default SpringJDBC Select Query In Clause More than 500

    Hi All,

    I am trying to solve the following issue, I have the following sql query.

    String sql = select * from db where value IN(?)

    the value of the (?) has to be supplied thru Java program and it happens to be like this.
    String value = "abc, def, a, b, c, d......." <- more then 500 string objects followed by comma which needs to be set in place of question mark.

    I am using following Spring function.

    public List<ListOrderedMap> getExtractOrders(final String sql, final String value) {
    final Object[] parameter = new Object[] { new String(value) };
    return this.getJdbcTemplate().queryForList(sql, parameter);
    }


    I think I am using some incorrect prepated statement...

    can somone please help ??

  2. #2
    Join Date
    Mar 2010
    Location
    USA
    Posts
    119

    Default

    Hi

    Your sql string should be something like this

    Code:
    String sql =select * from <db> where <value>  in (:listNameHere)
    and you can set the parameter using the following syntax

    Code:
    session.createSQLQuery("").setParameterList(arg0, arg1)
    Let me know whether this helps

    Thanks
    Priya
    Myblog: Spring/Java Programming tips

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •