Announcement Announcement Module
Collapse
No announcement yet.
Help using jdbcTemplate with stored procedures and java 1.4 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help using jdbcTemplate with stored procedures and java 1.4

    I'm trying to implement jdbcTemplate for accessing the DB in my application. We are using stored procedures (I found an example of using stored procedures with inputs) and we are using Java 1.4, so when I try to do the following:

    Code:
    String sql = sqlProcVMSGetItems;
    List lFormItems = new List();
    Date today = new Date();
            
    Object[] params = new Object [] {new Integer(formId), new Integer(0), new Date(today.getTime())};
        	
    int [] types = new int [] {Types.INTEGER, Types.INTEGER, Types.DATE};
        	
    lFormItems = jdbcTemplate.query(sql, params, types, new FormItemMapper());
    (I see I can use query(String, Object [], rowMapper) since I'm defining the type when creating the object array)

    I get a type mismatch error (can't convert a List to List). I've been looking for other examples but to no avail.

    Is there another way I can access my data?

    Also, I should be able to use this query statement for a single row or multiple row result set correct?

  • #2
    Since java.util.List is an interface you can't say:
    List lFormItems = new List();
    Its possible that lFormItems isn't a java.util.List.

    Comment


    • #3
      Have you tried using the JdbcTemplate's queryForList method?

      List queryForList(String sql, Object[] args, int[] argTypes, Class elementType)
      Query given SQL to create a prepared statement from SQL and a list of arguments to bind to the query, expecting a result list.

      Comment

      Working...
      X