可能是你在用完数据库连接的时候忘记关闭了
记得用con.close()来关闭数据库

解决方案 »

  1.   

    就是在servlet中processRequest(HttpServletRequest request, HttpServletResponse response)建立的
      

  2.   

    这个servlet需要2次连接数据库查询数据,其中一次是在一个自定义函数中,那么我是否需要
    2次定义con马?我觉得定义一个public就可以了吧
      

  3.   

    建议将你的数据库操作放到单独的方法中,在每次取数据时都调用,每次用完后记得关闭。
    你现在的问题是在第一次操作之后,关闭掉了数据库连接,在第二次操作时没有连接数据库,所以抛出了上面的异常。
    另外,processRequest我没试过,但在init方法中所有的操作,在每个会话周期中只调用一次。比如说,你把连接数据库的操作放到了init方法里,二关闭数据库连接的操作在别的方法里,那么在一个会话周期中多次调用同一个servlet的话,就会出现你的问题。
    public class MyServlet extends HttpServlet { 
      Connection conn = null;
      public void init(...) {
        conn = ...;
      }
      
      public void yourFuction() {
        ...
        conn.close();
      }
    }
    向上面的用法是要报你的错误的!建议改为
    public void yourFuction() {
      Connection conn = ...;
      ...
      conn.close();
    }
      

  4.   

    i think i have gotton the reason by myself.
    i have one class whose function is getting connection with oracle in which there is a
    Connection object.i must creat another Connection object to receive the Connection
    return value when i invoke the class.so there r 2 connection object.i have do to do with
    these two Connection object when i need data from db.there must be some problem.
    once more i think feibaook(飞豹) and other netpla's feedback.thanks!