java.sql.SQLException:检索结果后的Exhausted Resultset

时间:2013-02-19 05:06:02

标签: java sql jsp plsql

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

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; 
  } 

0 个答案:

没有答案