Hi, I've just found one subtle problem the Struts implementation 
of DataSource. 

My code looks something like this:

      ...
      Connection con = this.dataSource.getConnection();
      try {
        PreparedStatement stmt = con.prepareStatement(sql);
        stmt.setString(1, id);
        ResultSet rs = stmt.executeQuery();
        String result = null;
        if (rs.next()) {
          result = rs.getString(1);
        }
        return result;
      } finally {
        con.close();
      }
      ...

Obviously, there is an error. I do not close either the ResultSet 
nor the Statement. But I do close the Connection, so that the 
connection is returned to the DataSource's pool.

I realized my error, because Oracle complained about too many
open cursors after a while.

Shouldn't the call to con.close() close all open statements or at 
least warn about open ones?

--
gR

Reply via email to