db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lily...@apache.org
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 GMT
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");



Mime
View raw message