0

我试图使用以下方法获取搜索结果,它会像java.sql.SQLException: Exhausted Resultset在 catch 块中一样留下错误。这是在检索结果后显示的。搜索似乎也很慢。

private static OracleConnection connection = null;
    private static OraclePreparedStatement ptmst = null;
    private static OracleResultSet rs = null;
    private static OracleCallableStatement cstmt = null;


 public static ArrayList particleSearch(BigDecimal myId,BigDecimal deId,String search_term,JspWriter out )throws Exception
  {
    StringBuffer sql = new StringBuffer();
    ArrayList particles = new ArrayList();
    try
    {

      connection = (OracleConnection) TransactionScope.getConnection();
      sql.append("select distinct(..)......... ");  
      ptmst = (OraclePreparedStatement)connection.prepareStatement(sql.toString());
      ptmst.setBigDecimal(1,deId);
      ptmst.setBigDecimal(2,myId);
      ptmst.setString(3,search_term);
      rs = (OracleResultSet)ptmst.executeQuery();               

      while (rs.next()) 
                {                  
                HashMap hashParticles = new HashMap();
                hashParticles.put("part1",rs.getString(1));
                hashParticles.put("part2",rs.getString(2)); 
                hashParticles.put("part3",rs.getBigDecimal(3));                                                 
                particles.add(hashParticles);
                }

       connection.commit();


     }
     catch (Exception e) {
        out.println("Er:"+e.toString());  ///// throws error:: Er:java.sql.SQLException: Exhausted Resultset 
        }
     finally {

            try {
                if (ptmst != null) {
                    ptmst.close();
                }
            } catch (Exception e) {
            out.println(e.toString());
            }

            try {
                if (connection != null) {
                    TransactionScope.releaseConnection(connection);
                }
            } catch (Exception e) {
            out.println(e.toString());
            }

        }
        return particles; 
  } 
4

0 回答 0