5 Replies Latest reply on Jul 18, 2011 10:01 PM by 866972

    Calling a store procedure and displaying as a drop down list

    866972
      Hi,

      I am trying to call a store procedure in my java class by creating a method :

      public ArrayList getXyz() throws SQLException {

      final String METHOD_NAME = "<getXyz>";
      Connection conn = null;
      CallableStatement proc = null;
      ResultSet rs = null;
      ArrayList al= new ArrayList();
      try {
      conn = _Mnp.getConnection();

      // Setup the call.
      proc = conn.prepareCall("{ call CHANGE_R (?) }"); ///// Name of my store proc is Change_R and has Code and description

      proc.registerOutParameter("reasonCode", Types.VARCHAR);

      proc.execute();

      rs = (ResultSet) proc.getObject(1);
      ResultSetMetaData md = rs.getMetaData();
      int columns = md.getColumnCount();
      while (rs.next()) {

      HashMap row = new HashMap();

      al.add(row);

      for(int i=1; i<=columns; i++){

      row.put(md.getColumnName(i),rs.getObject(i));
      }

      }

      if (rs != null)
      rs.close();
      }
      catch (SQLException e) {

      proc.close();
      conn.close();

      }
      return al;
      }


      Now i want to call this method in my JSP and display the results as drop down list on my web page and I don't know how to proceed for that...Can you let me know how should i approach this ?

      Thanks