Results 1 to 6 of 6

Thread: handling xml results from storedprocedure

Hybrid View

  1. #1

    Default handling xml results from storedprocedure

    hi
    I need to call a stored procedure and the results I'm expecting in xml format.
    How do i persisit these xmlresults ,can somebody put me in right direction?or may be a sample pelase.

    thanks
    AD

  2. #2
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    I don't understand. The stored procedure is going to return XML and you want to know how to persist the XML?
    Last edited by karldmoore; Aug 30th, 2007 at 05:29 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  3. #3

    Default

    yes karldmore

    right now i have the code like this but this is map of result set which I'm processing , but I'm, expecting now results in xml format, how to persist them.

    present code
    Code:
    private class MyStoredProcedure extends StoredProcedure {
    		
    		/** Name of procedure in database. */
    		public static final String PROC_NAME = "sp_customerLookup";
    
    		//private int count = 0;
    		
    		/**
    		  * Constructor for this StoredProcedure class.
    		  * @param ds Data Source.
    		  */
    
    
    		public MyStoredProcedure(DataSource ds) {
    			setDataSource(ds);
    			setFunction(false);
    			setSql(PROC_NAME);
    
    			
    			declareParameter(new SqlReturnResultSet("rs", new RowMapper() {
    				public Object mapRow(ResultSet rs, int rowNum)
    						throws SQLException {
    					Map data = new HashMap(1);
                    //	 add more mappings here
    					data.put("id", rs.getString(1));
    					data.put("firstname", rs.getString(2));
    					data.put("lastname", rs.getString(3));
    					data.put("dob", rs.getString(4));
    					
    					return data;
    				}
    			}));
    			
                   // Parameters should be declared in same order here that
    			   // they are declared in the stored procedure.
    			declareParameter(new SqlParameter("id", Types.INTEGER));
    			declareParameter(new SqlParameter("surname", Types.VARCHAR));
    			declareParameter(new SqlParameter("firstname", Types.VARCHAR));
    			declareParameter(new SqlParameter("dob", Types.VARCHAR));
    			compile();
    		}
    
    public Map execute(Integer id,String lName, String fName,String dob) {
    			Map in = new HashMap();
    			in.put("id", id);
    			in.put("surname", lName);
    		    in.put("firstname", fName);
    			in.put("dob", dob);
    
    			Map out = execute(in);
    			return out;
    		}

  4. #4
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Are you saying the ResultSet currently returns String's but you are now going to be returning an XML type? You want to know how to read that out?
    Last edited by karldmoore; Aug 30th, 2007 at 05:29 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  5. #5

    Default

    yes karldmore

  6. #6
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    I've never used this myself, but I'm sure there have been posts on here in the past related to this. You might want to do a search.
    Last edited by karldmoore; Aug 30th, 2007 at 05:29 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

Posting Permissions

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