Uploaded image for project: 'Commons DBCP'
  1. Commons DBCP
  2. DBCP-309

First example for FSContext is invalid

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • 1.2.2
    • 1.5.1, 2.0
    • 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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            barkh Ondrej Tisler
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: