递归JDBC查询在oracle.jdbc.driver.T4CMAREngine.getNBytes(T4CMAREngine.java:1525)

时间:2016-06-13 15:42:29

标签: java oracle recursion jdbc

我正在运行一个遍历深层结构层次结构的程序。它是与机械装配相关的数据,其中一个组件报告给其他组件报告给其他组件。它有许多这样的级别。

在递归方法中,我从池中获取数据库连接并执行查询以获取相应的数据并关闭连接。然后它进入递归方法的下一个级别。程序运行多个小时,因为有大量数据需要处理。

在某些时候它会抛出以下错误。出现此错误后,如果我重新启动程序,它会很快失败并出现相同的错误。它与数据无关,因为每次都会在不同的地方抛出错误。

Exception in thread "main" java.lang.StackOverflowError
    at oracle.jdbc.driver.T4CMAREngine.getNBytes(T4CMAREngine.java:1525)
    at oracle.jdbc.driver.T4CMAREngine.unmarshalNBytes(T4CMAREngine.java:1495)
    at oracle.jdbc.driver.T4CMAREngine.unmarshalBuffer(T4CMAREngine.java:2009)
    at oracle.jdbc.driver.T4CMAREngine.unmarshalCLR(T4CMAREngine.java:1796)
    at oracle.jdbc.driver.T4CMAREngine.unmarshalCLR(T4CMAREngine.java:1930)
    at oracle.jdbc.driver.T4CMAREngine.unmarshalDALC(T4CMAREngine.java:2352)
    at oracle.jdbc.driver.T4C8TTIuds.unmarshal(T4C8TTIuds.java:134)
    at oracle.jdbc.driver.T4CTTIdcb.receiveCommon(T4CTTIdcb.java:155)
    at oracle.jdbc.driver.T4CTTIdcb.receive(T4CTTIdcb.java:115)
    at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:705)
    at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:210)
    at oracle.jdbc.driver.T4CStatement.executeForDescribe(T4CStatement.java:804)
    at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1049)
    at oracle.jdbc.driver.T4CStatement.executeMaybeDescribe(T4CStatement.java:845)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1154)
    at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1313)
    at com.hierarchy.HierarchyWalker.recursiveWalk(HierarchyWalker.java:420)
    at com.hierarchy.HierarchyWalker.recursiveWalk(HierarchyWalker.java:502)
    at com.hierarchy.HierarchyWalker.recursiveWalk(HierarchyWalker.java:502)
    at com.hierarchy.HierarchyWalker.recursiveWalk(HierarchyWalker.java:502)
    at com.hierarchy.HierarchyWalker.recursiveWalk(HierarchyWalker.java:502)
    at com.hierarchy.HierarchyWalker.recursiveWalk(HierarchyWalker.java:502)
    at com.hierarchy.HierarchyWalker.recursiveWalk(HierarchyWalker.java:502)
    at com.hierarchy.HierarchyWalker.recursiveWalk(HierarchyWalker.java:502)
    at com.hierarchy.HierarchyWalker.recursiveWalk(HierarchyWalker.java:502)
    at com.hierarchy.HierarchyWalker.recursiveWalk(HierarchyWalker.java:502)
    at com.hierarchy.HierarchyWalker.recursiveWalk(HierarchyWalker.java:502)
    at com.hierarchy.HierarchyWalker.recursiveWalk(HierarchyWalker.java:502)
    at com.hierarchy.HierarchyWalker.recursiveWalk(HierarchyWalker.java:502)
    at com.hierarchy.HierarchyWalker.recursiveWalk(HierarchyWalker.java:502)

代码是这样的。递归调用此方法直到它到达结尾。

public static void recursiveWalk(String parent){
         Connection conn = conPool.getConnection();
                  ......                       
              String queryStr= "SELECT childkey from Hierarchy where parentkey='"+parent+"'";                    

               stmt =  conn.createStatement();
             rs1 = stmt.executeQuery(queryStr);

              ...........
                  ArrayList aList = new ArrayList();
              while(rs1.next()){   
                 aList.add(rs1.getString("childkey"));

              } 
              rs1.close();
              stmt.close();
              conn.close();  
              for(aList){
              recursiveWalk(tempchild[1],schema,queryTail,topparent,addedchild,  poolconn,level+1);
              }
    }

0 个答案:

没有答案