Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 19748 invoked from network); 11 Feb 2011 23:21:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 11 Feb 2011 23:21:30 -0000 Received: (qmail 97180 invoked by uid 500); 11 Feb 2011 23:21:30 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 97139 invoked by uid 500); 11 Feb 2011 23:21:29 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 97132 invoked by uid 99); 11 Feb 2011 23:21:29 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Feb 2011 23:21:29 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Feb 2011 23:21:27 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 744DB23888CB; Fri, 11 Feb 2011 23:21:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1069981 - in /db/derby/code/trunk/java: engine/org/apache/derby/jdbc/AutoloadedDriver.java engine/org/apache/derby/jdbc/InternalDriver.java testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AutoloadTest.java Date: Fri, 11 Feb 2011 23:21:06 -0000 To: derby-commits@db.apache.org From: lilywei@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110211232106.744DB23888CB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: lilywei Date: Fri Feb 11 23:21:06 2011 New Revision: 1069981 URL: http://svn.apache.org/viewvc?rev=1069981&view=rev Log: DERBY-5029, DERBY-2095 getParentLogger() won't work after the engine has been shut down onece. Change comments and AutoloadTest per Dag's comments. Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver.java db/derby/code/trunk/java/engine/org/apache/derby/jdbc/InternalDriver.java db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AutoloadTest.java Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver.java?rev=1069981&r1=1069980&r2=1069981&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver.java Fri Feb 11 23:21:06 2011 @@ -61,11 +61,11 @@ public class AutoloadedDriver implements private static boolean _engineForcedDown = false; - //This is the driver that memorizes the autoloadeddriver (DERBY-2905) + // This is the driver that memorizes the autoloadeddriver (DERBY-2905) private static Driver _autoloadedDriver; - //This flag is set is deregister attribute is set by user, - //default is true (DERBY-2905) + // This flag is true unless the deregister attribute has been set to + // false by the user (DERBY-2905) private static boolean deregister = true; // // This is the driver that's specific to the JDBC level we're running at. @@ -228,7 +228,8 @@ public class AutoloadedDriver implements try { if (_autoloadedDriver == null) { - _autoloadedDriver = new AutoloadedDriver(); + //Support JDBC 4 or higher (DERBY-2905) + _autoloadedDriver = makeAutoloadedDriver(); DriverManager.registerDriver(_autoloadedDriver); } } catch (SQLException e) { @@ -283,5 +284,20 @@ public class AutoloadedDriver implements return deregister; } + /** + * load slightly more capable driver if possible. + * But if the vm level doesn't support it, then we fall + * back on the JDBC3 level driver. + * @return AutoloadedDriver + */ + private static AutoloadedDriver makeAutoloadedDriver() + { + try { + return (AutoloadedDriver) Class.forName( "org.apache.derby.jdbc.AutoloadedDriver40" ).newInstance(); + } + catch (Throwable t) {} + + return new AutoloadedDriver(); + } } Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/InternalDriver.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/InternalDriver.java?rev=1069981&r1=1069980&r2=1069981&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/InternalDriver.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/InternalDriver.java Fri Feb 11 23:21:06 2011 @@ -224,7 +224,8 @@ public abstract class InternalDriver imp } // DERBY-2905, allow users to provide deregister attribute to - // left AutoloadedDriver in DriverManager, default value is true + // leave AutoloadedDriver registered in DriverManager, default + // value is true if (finfo.getProperty(Attribute.DEREGISTER_ATTR) != null) { boolean deregister = Boolean.valueOf( finfo.getProperty(Attribute.DEREGISTER_ATTR)) Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AutoloadTest.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AutoloadTest.java?rev=1069981&r1=1069980&r2=1069981&view=diff ============================================================================== --- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AutoloadTest.java (original) +++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AutoloadTest.java Fri Feb 11 23:21:06 2011 @@ -186,7 +186,7 @@ public class AutoloadTest extends BaseJD /** * Test DERBY-2905:Shutting down embedded Derby does remove all code, - * the AutoloadDriver is dergistered from DriverManager. + * the AutoloadDriver is deregistered from DriverManager. * * @throws Exception */ @@ -224,8 +224,6 @@ public class AutoloadTest extends BaseJD user = getTestConfiguration().getUserName(); password = getTestConfiguration().getUserPassword(); DriverManager.getConnection(url, user, password); - //newInstance is gettin AutoloadedDriver - AutoloadedDriver = "org.apache.derby.jdbc.AutoloadedDriver"; assertTrue(getRegisteredDrivers(AutoloadedDriver)); // shut down engine @@ -510,7 +508,7 @@ public class AutoloadTest extends BaseJD //Case 2: Test with deregister=false, AutoloadedDriver should //still be in DriverManager JDBCDataSource.setBeanProperty(ds, "connectionAttributes", - "shutdown=tru e;deregister=false"); + "shutdown=true;deregister=false"); try { ds.getConnection(); fail("expected shutdown to fail");