回 帖 发 新 帖 刷新版面

主题:请帮忙看看我的程序怎么总是抛出“ORA-01000: 超出打开游标的最大数”异常

我的程序的部分代码为:
    Connection con = null;
             //Statement stmt =null;
             PreparedStatement pstmt = null;
             ResultSet rstm = null;
             ResultSet rs = null;
             
            String url = urlRoot + dbName;
         try {
               Class.forName(jdbcDriver);
               DriverManager.registerDriver(new OracleDriver());  
               con = DriverManager.getConnection(url, user, password);
                 con.setAutoCommit(false);
                  while((s = in.readLine()) != null){
                    if(s.contains(">")){
                        if(s.contains("|") & s.contains("- "))
                        {
                          int begin = s.indexOf("|");
                          int end = s.lastIndexOf("- ");
                           proID = s.substring(0, begin).trim();
                        
                            abstractFunction = s.substring((begin + 1), end).trim();
                           organism = s.substring((end + 1)).trim();
                           }                            
                        
                    }
                    else {
                        sequense = s;
                        if(proID != "" & sequense != "" ){
                            try{
                                
                                   CLOB clob = null;
                                   if(pstmt == null)
                                  pstmt = con.prepareStatement("select proid from maliky_first.uniproswiss where proid = ?");
                                  pstmt.setString(1, proID);
                                  rstm = pstmt.executeQuery();
                                  if (!rstm.next()){                                      
                                      pstmt.close();
                                      pstmt = null;
                                     
                                  pstmt = con.prepareStatement("INSERT INTO maliky_first.uniproswiss (proid,sequense,abstractfunction,organism) VALUES(?,empty_clob(),?,?)");
                                  pstmt.setString(1,proID);
                                  pstmt.setString(2,abstractFunction);
                                  pstmt.setString(3,organism);
                                  pstmt.executeUpdate();
                                  pstmt.close();

                                  pstmt = con.prepareStatement("select sequense from maliky_first.uniproswiss where proid= ? for update");
                                  pstmt.setString(1,proID);
                                  rs = pstmt.executeQuery();
                                  if (rs.next()) clob = (CLOB) rs.getClob(1);
                                  rs.close();

                                  pstmt = con.prepareStatement("update maliky_first.uniproswiss set sequense=? where proid=?");

                                  Writer out = clob.getCharacterOutputStream();
                                  out.write(sequense);
                                  
                                  out.close();

                                  pstmt.setClob(1,clob);
                                  pstmt.setString(2,proID);

                                  pstmt.executeUpdate();
                                  pstmt.close();                                                                
                                                                    
                                  }
                                  
                                  rstm.close();
                                  pstmt.close();   
                            }catch(SQLException e){
                                System.out.println(proID);
                                 System.err.println(e.getMessage());
                                 System.err.println(e.getLocalizedMessage());
                            }finally{
                                  try
                                    {
                                    if (pstmt != null)
                                        pstmt.close();
                                    }
                                    catch(Exception e) {}
                                    try
                                    {
                                    if (rs != null)
                                        rs.close();
                                    }
                                    catch(Exception e) {}
                                    try
                                    {
                                    if (rstm != null)
                                        rstm.close();
                                    }
                                    catch(Exception e) {}
                                    pstmt = null;
                                    rs = null;
                                    rstm = null;
                                    
                                    
                            }
                            }
                            
                            
                        }
                        
                }
                  con.commit();
                  con.close();
         } catch (ClassNotFoundException e) {
               System.err.println(e.getMessage());
              }catch(SQLException e){
                  System.err.println(e.getMessage());
              }finally{
                  try
                    {
                    if (pstmt != null)
                        pstmt.close();
                    }
                    catch(Exception e) {}
                    
                    try
                    {
                    if (con != null)
                    con.close();
                    }
                    catch (Exception e){}
                    try
                    {
                    if (rs != null)
                        rs.close();
                    }
                    catch(Exception e) {}                
                    
                    try
                    {
                    if (rstm != null)
                        rstm.close();
                    }
                    catch(Exception e) {}
                    
            }
                
        
    }

回复列表 (共2个回复)

沙发

自己顶,怎么没有回复

板凳

连注释都没有
要看懂也要大半天吧?
谁有这么多时间?

我来回复

您尚未登录,请登录后再回复。点此登录或注册