Commons Dbcp
  1. Commons Dbcp
  2. DBCP-309

First example for FSContext is invalid

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: 1.2.2
    • Fix Version/s: 1.5.1, 2.0
    • Labels:
      None

      Description

      First example on page http://commons.apache.org/dbcp/guide/jndi-howto.html is invalid, with this code every call of

      InitialContext ic2 = new InitialContext();
      DataSource ds = (DataSource) ic2.lookup("jdbc/basic");
      Connection conn = ds.getConnection();
      conn.close();

      ends with new datasource with unclosed connection in it becase new Reference("javax.sql.DataSource", "org.apache.commons.dbcp.BasicDataSourceFactory", null); reference creates new DataSource instead using created one while calling ic2.lookup("jdbc/basic").

      At the end it ends with many opened connections to DB until JVM is ended.

      Second example I didn't test, i use direct aproach with manualy creating SharedPoolDataSource and registring it in FSContext JNDI itself.

        Activity

          People

          • Assignee:
            Unassigned
            Reporter:
            Ondrej Tisler
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development