Announcement Announcement Module
Collapse
No announcement yet.
Difference between SimpleJdbcTemplate and JdbcCall Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Difference between SimpleJdbcTemplate and JdbcCall

    Hi all,
    though i use both in my project but not very clear on differences.
    I know that SimpleJdbcTemplate is used to run queries directly from java using methods like queryForInt()
    and JdbcCall is used to call stored procedures and functions.

    1. Is there any other difference performance wise.
    2. Also which one is advisable way under what conditions? To use query directly in java or put it into a stored procedure,return a cursor
    and fetch it into list or any kind of variable.

  • #2
    Difference between SimpleJdbcTemplate and JdbcCall

    This direct execution through jdbctemplate returns fetchsize of 200 in the row mapper
    jdbcTemplate = new JdbcTemplate(ds);
    jdbcTemplate.setResultsMapCaseInsensitive(true);
    jdbcTemplate.setFetchSize(200);

    List temp = jdbcTemplate.query("select 1 from dual", new ParameterizedRowMapper() {
    public Object mapRow(ResultSet resultSet, int i) throws SQLException {
    System.out.println("Direct template : " + resultSet.getFetchSize());
    return new String(resultSet.getString(1));
    }
    });

    This execution through SimpleJdbcCall is always returning fetchsize of 10 in the rowmapper
    jdbcCall = new SimpleJdbcCall(jdbcTemplate).withSchemaName(schema Name)
    .withCatalogName(catalogName).withProcedureName(fu nctionName);
    jdbcCall.returningResultSet((String) outItValues.next(), new ParameterizedRowMapper<Map<String, Object>>() {
    public Map<String, Object> mapRow(ResultSet rs, int row) throws SQLException {
    System.out.println("Through simplejdbccall " + rs.getFetchSize());
    return extractRS(rs, row);
    }
    });
    outputList = (List<Map<String, Object>>) jdbcCall.executeObject(List.class, inParam);

    Comment


    • #3
      http://www.w3schools.com/

      Comment

      Working...
      X