2 Replies Latest reply on Mar 8, 2002 2:14 PM by jredner

    Stateless Session Bean & JDBC

    jredner

      Is there something I need to do to clean up a DB connection in a Stateful session bean? If I reload the same bean I get an exception from the following method if it's Stateful. It's fine if it's Stateless.



      public String showCustInfo(String custno) {
      call_count ++;


      String result = "n/a";

      try {
      Context ctx = new InitialContext();

      DataSource ds = (DataSource)ctx.lookup("java:/OracleDS");
      Connection con = ds.getConnection();

      Statement stmt = con.createStatement();
      ResultSet rs = stmt.executeQuery("select * from dual");

      while (rs.next()) {
      result = rs.getString(1);
      }

      con.close();


      } catch (Exception e) {
      System.out.println("Exception: " + e.getMessage());
      }

      return("Result: " + result);

      }


      Thanks in advance!