title: Connection getting closed while executing oracle.sql.ARRAY.getArray() in spring stored procedure implementation
body: <p>I am facing a problem while trying to read OUT parameter of a stored procedure using Spring's stored procedure implementation. The OUT parameter is a custom/user defined ORACLE type. Find below the implementation detail. Please let me know how to get around the problem.</p>
  
  <pre><code>import java.sql.Connection;
  import java.sql.PreparedStatement;
  import java.sql.SQLException;
  import java.util.HashMap;
  import java.util.Map;
  
  import javax.sql.DataSource;
  
  import oracle.jdbc.OracleTypes;
  import oracle.sql.ARRAY;
  import oracle.sql.ArrayDescriptor;
  
  import org.apache.log4j.Logger;
  import org.springframework.jdbc.core.SqlOutParameter;
  import org.springframework.jdbc.core.SqlParameter;
  import org.springframework.jdbc.core.SqlTypeValue;
  import org.springframework.jdbc.object.StoredProcedure;
  
  import com.***.****.bean.ExcelListenerBean;
  import com.***.****.bean.RevAppViewBean;
  
  public class RevPrdBrkDwnSP extends StoredProcedure{
  
      private final Logger log = Logger.getLogger(this.getClass().getName());
  
      public RevPrdBrkDwnSP(DataSource dataSource, String storeProcName) throws SQLException {
  
          // Run the Parent
          super(dataSource, storeProcName);
  
          if (log.isInfoEnabled()) {
              log.info("PBAREV product breakdown processes Stored Procedure Name : "+ storeProcName);
          }
          // Declare the Parameter Details
          declareParameter(new SqlParameter("IN_ARRAY", OracleTypes.ARRAY, "PBAREV.PROD_PRCT_BRKDWN_TYPE_ARRAY"));
          declareParameter(new SqlOutParameter("OUT_ARRAY", OracleTypes.ARRAY, "PBAREV.PROD_PRCT_BRKDWN_TYPE_ARRAY"));
  
          // Compile the SP
          compile();
      }
  
      public boolean execute(final RevAppViewBean appViewBean$Session, final DataSource dataSource) throws Exception {
          boolean returnVal = false;
          Map&lt;String, Object&gt; inParams = new HashMap&lt;String, Object&gt;();
          log.info("Setting up the Store Procedure Params");
  
          inParams.put("IN_ARRAY", new SqlTypeValue() {
              public void setTypeValue(PreparedStatement cs, int index, int sqlType, String typeName) throws SQLException {
                  Connection con = cs.getConnection();
                  ArrayDescriptor des = ArrayDescriptor.createDescriptor("PBAREV.PROD_PRCT_BRKDWN_TYPE_ARRAY", con);
                  ARRAY a = new ARRAY(des, con, appViewBean$Session.getExcelRecLst().toArray());
                  cs.setObject(1, (Object)a);
              }
          });
  
          if (log.isDebugEnabled()) {
              log.debug("Executing the PBAREV Store Procedure ");
          }
  
          final Map out = super.execute(inParams);
          log.info("output size is ---------------------&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; "+out.size()); //prints the actual value
  
          ARRAY returnValue = (ARRAY)out.get("OUT_ARRAY");
          log.info("size of returnValue is "+returnValue.length()); //prints th right number of results
  
          Object[] idOutArraz = (Object[])returnValue.getArray(); // Error is thrown from this location
  
          for(int i= 0; i&lt;idOutArraz.length;i++){
              ExcelListenerBean bean = (ExcelListenerBean) idOutArraz[i];
          }
  
          log.info(returnValue);
  
          if (log.isDebugEnabled()) {
              log.info("Output from PBAREV Store Procedure :" + out);
          }
  
          return returnVal;
      }
  }
  </code></pre>
  
  <p>The stack trace of the exception is as follows.</p>
  
  <pre><code>Caused by: java.lang.NullPointerException
      at oracle.jdbc.driver.OracleConnection.safelyGetClassForName(OracleConnection.java:5074)
      at oracle.jdbc.driver.OracleConnection.addClassMapEntry(OracleConnection.java:2852)
      at oracle.jdbc.driver.OracleConnection.addDefaultClassMapEntriesTo(OracleConnection.java:2843)
      at oracle.jdbc.driver.OracleConnection.initializeClassMap(OracleConnection.java:2529)
      at oracle.jdbc.driver.OracleConnection.ensureClassMapExists(OracleConnection.java:2523)
      at oracle.jdbc.driver.OracleConnection.getTypeMap(OracleConnection.java:2829)
      at oracle.sql.ARRAY.getMap(ARRAY.java:863)
      at oracle.sql.ARRAY.getArray(ARRAY.java:370)
      at com.****.****.****.RevPrdBrkDwnSP.execute(RevPrdBrkDwnSP.java:68)
      at com.*****.****.*****.****.IBatisRevPrdBrkDwnDao.runPrdBrkDwnProcess(IBatisRevPrdBrkDwnDao.java:24)
  </code></pre>