Results 1 to 2 of 2

Thread: Spring JDBC Storedproc example

  1. #1
    Join Date
    Nov 2004
    Posts
    11

    Default Spring JDBC Storedproc example

    How to implement the code below using Spring Storedproc? Can't find a more complex example anywhere...

    Thanks,

    Code:
    public Collection getAddresses(String pid) {
            Connection conn = null;
            CallableStatement cstmt = null;
            ResultSet rs = null;
    
            Address address = null;
    
            Collection result = null;
    
            try {
                conn = ds.getConnection();
                cstmt = conn.prepareCall(DATA_ADDR_READ_PROC_NAME);
    
                cstmt.setString(1, pid);
    
                boolean returnedResultSet = cstmt.execute();
    
                result = new ArrayList();
                while (true) {
                    rs = cstmt.getResultSet();
                    if (rs != null) {
          
    
                        while (rs.next()) {
    
                            address = new Address(rs);
                            
                            result.add(address);
    
                        }
                    }
    
             
                    if ((cstmt.getMoreResults() == false) && (cstmt.getUpdateCount() == -1))
                        break;
                }
    
            } catch (SQLException ex) {
                log.error(ex);
                throw new DataAccessException(ex);
            } finally {
                closeResultSet(rs);
                closeStatement(cstmt);
                closeConnection(conn);
            }
    
            return result;
        }

  2. #2
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    736

    Default

    I'm about 100% sure that if you search on the forums for "stored proc" or "stored procedure" you'll find some examples of doing stored procs. I know I saw some from Thomas Risberg, for example.
    Colin Sampaleanu
    SpringSource - http://www.springsource.com

Similar Threads

  1. Spring MVC Web Framework versus Struts
    By biguniverse in forum Web Flow
    Replies: 27
    Last Post: Aug 29th, 2012, 03:57 AM
  2. Spring JDBC for unit tests?
    By amkush in forum Data
    Replies: 7
    Last Post: Aug 20th, 2008, 02:29 PM
  3. JDBC MetaData Through Spring?
    By gaffonso in forum Data
    Replies: 9
    Last Post: Feb 7th, 2006, 06:41 PM
  4. Replies: 2
    Last Post: Jul 19th, 2005, 07:30 AM
  5. Replies: 14
    Last Post: Feb 21st, 2005, 05:41 PM

Posting Permissions

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