Results 1 to 2 of 2

Thread: How to pass an int parameter to NamedParameterJdbcTemplate.query()

  1. #1
    Join Date
    Mar 2012
    Posts
    5

    Default How to pass an int parameter to NamedParameterJdbcTemplate.query()

    Hi,

    Since i am new to spring can somebody help me on the below issue.

    I am trying to call NamedParameterJdbcTemplate.query(String query,Map param, RowMapper rm)
    I need to pass an integer value to the param map.

    The query is something like SELECT NAME FROM TABLE1 WHERE AGE = :age and the map is something like the below,

    Map<String, Object> params = new HashMap<String, Object>();
    params.put("age", new Integer(20));

    So when i call NamedParameterJdbcTemplate.query("SELECT NAME FROM TABLE1 WHERE AGE = :age",params, rm), the place holder :age is never replaced with 20 and the query always fails.

    What object type has to be used when i have an integer parameter..?.
    My db is Oracle and column type is NUMBER.

  2. #2
    Join Date
    Mar 2012
    Posts
    5

    Default

    am a big stupid only..it was the problem with the rowmapper....

Posting Permissions

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