Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 14815 invoked from network); 2 Dec 2009 13:06:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 Dec 2009 13:06:46 -0000 Received: (qmail 3147 invoked by uid 500); 2 Dec 2009 13:06:45 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 2905 invoked by uid 500); 2 Dec 2009 13:06:44 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 2895 invoked by uid 99); 2 Dec 2009 13:06:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Dec 2009 13:06:44 +0000 X-ASF-Spam-Status: No, hits=-10.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Dec 2009 13:06:42 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 3FC56234C1F0 for ; Wed, 2 Dec 2009 05:06:22 -0800 (PST) Message-ID: <947754503.1259759182260.JavaMail.jira@brutus> Date: Wed, 2 Dec 2009 13:06:22 +0000 (UTC) From: "Ondrej Tisler (JIRA)" To: issues@commons.apache.org Subject: [jira] Commented: (DBCP-309) First example for FSContext is invalid In-Reply-To: <147404332.1259244819784.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/DBCP-309?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12784807#action_12784807 ] Ondrej Tisler commented on DBCP-309: ------------------------------------ I use this code for registring JNDI inFSContext: // JNDI with datasource InitialContext ic = new InitialContext(); // Construct BasicDataSource reference Configuration poolConfig = dbConfig.subset("datasource"); DriverAdapterCPDS cpds = new DriverAdapterCPDS(); cpds.setDriver(poolConfig.getString("driver.driverClassName")); cpds.setUrl(poolConfig.getString("driver.url")); cpds.setUser(poolConfig.getString("driver.username")); cpds.setPassword(CryptPass.encryptPass(poolConfig.getString("driver.password"))); SharedPoolDataSource ds = new SharedPoolDataSource(); ds.setConnectionPoolDataSource(cpds); ds.setDefaultAutoCommit(poolConfig.getBoolean("connection.defaultAutoCommit", true)); ds.setValidationQuery(poolConfig.getString("validation.validationQuery")); ic.rebind(poolConfig.getString("[@jndi]"), ds); log.info("JNDI datasource is inicialized"); next you can normaly use JNDI lookup: InitialContext ic2 = new InitialContext(); ds = (DataSource) ic2.lookup(poolConfig.getString("[@jndi]")); conn = ds.getConnection(); > First example for FSContext is invalid > -------------------------------------- > > Key: DBCP-309 > URL: https://issues.apache.org/jira/browse/DBCP-309 > Project: Commons Dbcp > Issue Type: Bug > Affects Versions: 1.2.2 > Reporter: Ondrej Tisler > Priority: Trivial > > 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. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.