You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2013/06/19 09:28:37 UTC

svn commit: r1494482 - in /db/derby/code/trunk: java/engine/org/apache/derby/ java/engine/org/apache/derby/jdbc/ java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ java/test...

Author: kahatlen
Date: Wed Jun 19 07:28:36 2013
New Revision: 1494482

URL: http://svn.apache.org/r1494482
Log:
DERBY-1984: Re-factor JDBC classes to remove support for JDBC 2

Move all functionality from Driver20, Driver30 and Driver40 to
InternalDriver. Move all functionality from AutoloadedDriver40
to AutoloadedDriver.

Removed:
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver40.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver20.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver30.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver40.java
Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/AutoloadedDriver.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/BasicEmbeddedConnectionPoolDataSource40.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/BasicEmbeddedXADataSource40.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver42.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedXADataSource.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/InternalDriver.java
    db/derby/code/trunk/java/engine/org/apache/derby/modules.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Driver.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/AutoloadTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DriverTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/RollBackWrappingWhenFailOnImportTest.java
    db/derby/code/trunk/tools/jar/extraDBMSclasses.properties

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=1494482&r1=1494481&r2=1494482&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 Wed Jun 19 07:28:36 2013
@@ -313,18 +313,15 @@ public class AutoloadedDriver implements
 	}
 	
     /**
-     * load slightly more capable driver if possible.
+     * Load the most capable driver available.
      * But if the vm level doesn't support it, then we fall
-     * back on the JDBC3 level driver.
+     * back on a lower-level driver.
      * @return AutoloadedDriver 
      */
     private static AutoloadedDriver makeAutoloadedDriver() 
-    { 
-        try { 
-            return (AutoloadedDriver) Class.forName( "org.apache.derby.jdbc.AutoloadedDriver40" ).newInstance(); 
-        } 
-        catch (Throwable t) {} 
-
+    {
+        // Currently, there's only one driver, and it supports all the JDBC
+        // levels that Derby supports. Return an instance of it.
         return new AutoloadedDriver(); 
     } 
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/BasicEmbeddedConnectionPoolDataSource40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/BasicEmbeddedConnectionPoolDataSource40.java?rev=1494482&r1=1494481&r2=1494482&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/BasicEmbeddedConnectionPoolDataSource40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/BasicEmbeddedConnectionPoolDataSource40.java Wed Jun 19 07:28:36 2013
@@ -85,7 +85,7 @@ public class BasicEmbeddedConnectionPool
             String password,
             boolean requestPassword) throws SQLException {
 
-        return ((Driver30) findDriver()).getNewPooledConnection(
+        return findDriver().getNewPooledConnection(
             this, user, password, requestPassword);
     }
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/BasicEmbeddedXADataSource40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/BasicEmbeddedXADataSource40.java?rev=1494482&r1=1494481&r2=1494482&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/BasicEmbeddedXADataSource40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/BasicEmbeddedXADataSource40.java Wed Jun 19 07:28:36 2013
@@ -104,7 +104,7 @@ public class BasicEmbeddedXADataSource40
             boolean requestPassword) throws SQLException {
 
         // See comment for EmbeddedXADataSource#createXAConnection
-        return ((Driver30) findDriver()).getNewXAConnection(
+        return findDriver().getNewXAConnection(
             this, ra, user, password, requestPassword);
     }
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver42.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver42.java?rev=1494482&r1=1494481&r2=1494482&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver42.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/Driver42.java Wed Jun 19 07:28:36 2013
@@ -30,8 +30,6 @@ import org.apache.derby.iapi.jdbc.Broker
 import org.apache.derby.iapi.jdbc.BrokeredConnection42;
 import org.apache.derby.iapi.sql.ResultSet;
 
-import org.apache.derby.iapi.services.sanity.SanityManager;
-import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.impl.jdbc.EmbedPreparedStatement42;
 import org.apache.derby.impl.jdbc.EmbedCallableStatement42;
 import org.apache.derby.impl.jdbc.EmbedConnection;
@@ -43,7 +41,7 @@ import org.apache.derby.impl.jdbc.EmbedR
  * Embedded JDBC driver for JDBC 4.2.
  * </p>
  */
-public class Driver42 extends Driver40
+public class Driver42 extends InternalDriver
 {
     public PreparedStatement newEmbedPreparedStatement
         (

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java?rev=1494482&r1=1494481&r2=1494482&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbedPooledConnection.java Wed Jun 19 07:28:36 2013
@@ -44,7 +44,6 @@ import java.sql.PreparedStatement;
 import java.sql.CallableStatement;
 
 import java.util.ArrayList;
-import java.util.Iterator;
 
 /* -- New jdbc 20 extension types --- */
 import javax.sql.ConnectionEventListener;
@@ -186,7 +185,7 @@ abstract class EmbedPooledConnection imp
 
 	final Connection getNewCurrentConnectionHandle() throws SQLException {
 		Connection applicationConnection = currentConnectionHandle =
-			((org.apache.derby.jdbc.Driver20) (realConnection.getLocalDriver())).newBrokeredConnection(this);
+            realConnection.getLocalDriver().newBrokeredConnection(this);
 		realConnection.setApplicationConnection(applicationConnection);
 		return applicationConnection;
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource.java?rev=1494482&r1=1494481&r2=1494482&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource.java Wed Jun 19 07:28:36 2013
@@ -139,7 +139,7 @@ public class EmbeddedConnectionPoolDataS
          * instantiating EmbeddedConnectionPoolDataSource) instead of
          * the newer one (EmbeddedConnectionPoolDataSource40).
          */
-        return ((Driver30) findDriver()).getNewPooledConnection(
+        return findDriver().getNewPooledConnection(
             this, user, password, requestPassword);
     }
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedXADataSource.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedXADataSource.java?rev=1494482&r1=1494481&r2=1494482&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedXADataSource.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedXADataSource.java Wed Jun 19 07:28:36 2013
@@ -172,7 +172,7 @@ public class EmbeddedXADataSource extend
          * instantiating EmbeddedXADataSource) instead of the newer one
          * (EmbeddedXADataSource40).
          */
-        return ((Driver30) findDriver()).getNewXAConnection(
+        return findDriver().getNewXAConnection(
             this, ra, user, password, requestPassword);
     }
 

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=1494482&r1=1494481&r2=1494482&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 Wed Jun 19 07:28:36 2013
@@ -22,51 +22,61 @@
 
 package org.apache.derby.jdbc;
 
+import java.security.AccessControlException;
+import java.security.Permission;
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.DriverPropertyInfo;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.sql.Statement;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.SynchronousQueue;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.logging.Logger;
+import javax.sql.PooledConnection;
+import javax.sql.XAConnection;
+import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.jdbc.AuthenticationService;
+import org.apache.derby.iapi.jdbc.BrokeredConnection;
+import org.apache.derby.iapi.jdbc.BrokeredConnectionControl;
+import org.apache.derby.iapi.jdbc.ConnectionContext;
+import org.apache.derby.iapi.jdbc.ResourceAdapter;
 import org.apache.derby.iapi.reference.Attribute;
+import org.apache.derby.iapi.reference.MessageId;
 import org.apache.derby.iapi.reference.Module;
+import org.apache.derby.iapi.reference.Property;
 import org.apache.derby.iapi.reference.SQLState;
-import org.apache.derby.iapi.reference.MessageId;
-import org.apache.derby.iapi.services.io.FormatableProperties;
-
-import org.apache.derby.iapi.jdbc.ConnectionContext;
-
-import org.apache.derby.iapi.services.monitor.ModuleControl;
-import org.apache.derby.iapi.services.monitor.Monitor;
-import org.apache.derby.iapi.services.context.ContextService;
+import org.apache.derby.iapi.security.SecurityUtil;
 import org.apache.derby.iapi.services.context.ContextManager;
-import org.apache.derby.iapi.services.sanity.SanityManager;
-import org.apache.derby.iapi.error.StandardException;
+import org.apache.derby.iapi.services.context.ContextService;
 import org.apache.derby.iapi.services.i18n.MessageService;
+import org.apache.derby.iapi.services.io.FormatableProperties;
 import org.apache.derby.iapi.services.jmx.ManagementService;
-
-import org.apache.derby.iapi.sql.ResultSet;
-
-import org.apache.derby.iapi.jdbc.AuthenticationService;
+import org.apache.derby.iapi.services.monitor.ModuleControl;
+import org.apache.derby.iapi.services.monitor.Monitor;
 import org.apache.derby.iapi.sql.ResultColumnDescriptor;
-
-import org.apache.derby.security.SystemPermission;
-
+import org.apache.derby.iapi.sql.ResultSet;
+import org.apache.derby.iapi.util.InterruptStatus;
 import org.apache.derby.impl.jdbc.*;
 import org.apache.derby.mbeans.JDBCMBean;
-
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.SQLException;
-
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-import java.security.Permission;
-import java.security.AccessControlException;
-
-import org.apache.derby.iapi.util.IdUtil;
-
+import org.apache.derby.security.SystemPermission;
 
 /**
-	Abstract factory class and api for JDBC objects.
-*/
-
-public abstract class InternalDriver implements ModuleControl {
+ * Factory class and API for JDBC objects.
+ */
+public class InternalDriver implements ModuleControl, Driver {
     
 	private static final Object syncMe = new Object();
 	private static InternalDriver activeDriver;
@@ -84,6 +94,13 @@ public abstract class InternalDriver imp
      */
     private static boolean deregister = true;
 
+    private static final ThreadPoolExecutor _executorPool =
+            new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS,
+                                   new SynchronousQueue<Runnable>());
+    static {
+        _executorPool.setThreadFactory(new DaemonThreadFactory());
+    }
+
 	public static final InternalDriver activeDriver()
 	{
 		return activeDriver;
@@ -111,6 +128,9 @@ public abstract class InternalDriver imp
                    new JDBC(this),
                    JDBCMBean.class,
                    "type=JDBC");
+
+        // Register with the driver manager
+        AutoloadedDriver.registerDriverModule(this);
 	}
 
 	public void stop() {
@@ -127,6 +147,8 @@ public abstract class InternalDriver imp
 		active = false;
 
 		contextServiceFactory = null;
+
+        AutoloadedDriver.unregisterDriverModule();
 	}
 
 	/*
@@ -287,23 +309,100 @@ public abstract class InternalDriver imp
     /**
      * Enforce the login timeout.
      */
-    protected abstract EmbedConnection  timeLogin( String url, Properties info, int loginTimeoutSeconds )
-        throws SQLException;
-    
+    EmbedConnection timeLogin(
+            String url, Properties info, int loginTimeoutSeconds)
+        throws SQLException
+    {
+        try {
+            LoginCallable callable = new LoginCallable(this, url, info);
+            Future<EmbedConnection> task = _executorPool.submit(callable);
+            long startTime = System.currentTimeMillis();
+            long interruptedTime = startTime;
+
+            while ((startTime - interruptedTime) / 1000.0
+                        < loginTimeoutSeconds) {
+                try {
+                    return task.get(loginTimeoutSeconds, TimeUnit.SECONDS);
+                } catch (InterruptedException ie) {
+                    interruptedTime = System.currentTimeMillis();
+                    InterruptStatus.setInterrupted();
+                    continue;
+                } catch (ExecutionException ee) {
+                    throw processException(ee);
+                } catch (TimeoutException te) {
+                    throw Util.generateCsSQLException(SQLState.LOGIN_TIMEOUT);
+                }
+            }
+
+            // Timed out due to interrupts, throw.
+            throw Util.generateCsSQLException(SQLState.LOGIN_TIMEOUT);
+        } finally {
+            InterruptStatus.restoreIntrFlagIfSeen();
+        }
+    }
+
+    /** Process exceptions raised while running a timed login. */
+    private SQLException processException(Throwable t) {
+        Throwable cause = t.getCause();
+        if (cause instanceof SQLException) {
+            return (SQLException) cause;
+        } else {
+            return Util.javaException(t);
+        }
+    }
+
+    /**
+     * Thread factory to produce daemon threads which don't block VM shutdown.
+     */
+    private static final class DaemonThreadFactory implements ThreadFactory {
+        public Thread newThread(Runnable r) {
+            Thread result = new Thread(r);
+            result.setDaemon(true);
+            return result;
+        }
+    }
+
+    /**
+     * This code is called in a thread which puts time limits on it.
+     */
+    public static final class LoginCallable implements
+            Callable<EmbedConnection> {
+
+        private InternalDriver _driver;
+        private String _url;
+        private Properties _info;
+
+        public LoginCallable(InternalDriver driver, String url, Properties info) {
+            _driver = driver;
+            _url = url;
+            _info = info;
+        }
+
+        public EmbedConnection call() throws SQLException {
+            // Erase the state variables after we use them.
+            // Might be paranoid but there could be security-sensitive info
+            // in here.
+            String url = _url;
+            Properties info = _info;
+            InternalDriver driver = _driver;
+            _url = null;
+            _info = null;
+            _driver = null;
+
+            return driver.getNewEmbedConnection(url, info);
+        }
+    }
+
     /**
      * Checks for System Privileges.
      *
-     * Abstract since some of the javax security classes are not available
-     * on all platforms.
-     *
      * @param user The user to be checked for having the permission
      * @param perm The permission to be checked
      * @throws AccessControlException if permissions are missing
-     * @throws Exception if the privileges check fails for some other reason
      */
-    abstract public void checkSystemPrivileges(String user,
-                                               Permission perm)
-        throws Exception;
+    public void checkSystemPrivileges(String user, Permission perm) {
+        SecurityUtil.checkUserHasPermission(user, perm);
+    }
 
     /**
      * Checks for shutdown System Privileges.
@@ -529,9 +628,10 @@ public abstract class InternalDriver imp
 		Methods to be overloaded in sub-implementations such as
 		a tracing driver.
 	 */
-	protected abstract EmbedConnection getNewEmbedConnection(String url, Properties info) 
-		 throws SQLException ;
-
+    EmbedConnection getNewEmbedConnection(String url, Properties info)
+            throws SQLException {
+        return new EmbedConnection(this, url, info);
+    }
 
 	private ConnectionContext getConnectionContext() {
 
@@ -575,23 +675,30 @@ public abstract class InternalDriver imp
 	 * @return A nested connection object.
 	 *
 	 */
-	public abstract Connection getNewNestedConnection(EmbedConnection conn);
+    public Connection getNewNestedConnection(EmbedConnection conn) {
+        return new EmbedConnection(conn);
+    }
 
 	/*
 	** methods to be overridden by subimplementations wishing to insert
 	** their classes into the mix.
 	*/
 
-	public abstract java.sql.Statement newEmbedStatement(
+    public Statement newEmbedStatement(
 				EmbedConnection conn,
 				boolean forMetaData,
 				int resultSetType,
 				int resultSetConcurrency,
-				int resultSetHoldability);
+                int resultSetHoldability)
+    {
+        return new EmbedStatement(conn, forMetaData, resultSetType,
+                resultSetConcurrency, resultSetHoldability);
+    }
+
 	/**
 	 	@exception SQLException if fails to create statement
 	 */
-	public abstract java.sql.PreparedStatement newEmbedPreparedStatement(
+    public PreparedStatement newEmbedPreparedStatement(
 				EmbedConnection conn,
 				String stmt, 
 				boolean forMetaData, 
@@ -601,25 +708,37 @@ public abstract class InternalDriver imp
 				int autoGeneratedKeys,
 				int[] columnIndexes,
 				String[] columnNames)
-		throws SQLException;
+        throws SQLException
+    {
+        return new EmbedPreparedStatement(conn,
+                stmt, forMetaData, resultSetType, resultSetConcurrency,
+                resultSetHoldability, autoGeneratedKeys, columnIndexes,
+                columnNames);
+    }
 
 	/**
 	 	@exception SQLException if fails to create statement
 	 */
-	public abstract java.sql.CallableStatement newEmbedCallableStatement(
+    public CallableStatement newEmbedCallableStatement(
 				EmbedConnection conn,
 				String stmt, 
 				int resultSetType,
 				int resultSetConcurrency,
 				int resultSetHoldability)
-		throws SQLException;
+        throws SQLException
+    {
+        return new EmbedCallableStatement(conn, stmt, resultSetType,
+                resultSetConcurrency, resultSetHoldability);
+    }
 
 	/**
 	 * Return a new java.sql.DatabaseMetaData instance for this implementation.
 	 	@exception SQLException on failure to create.
 	 */
-	public abstract DatabaseMetaData newEmbedDatabaseMetaData
-        (EmbedConnection conn, String dbname) throws SQLException;
+    public DatabaseMetaData newEmbedDatabaseMetaData(
+            EmbedConnection conn, String dbname) throws SQLException {
+        return new EmbedDatabaseMetaData(conn, dbname);
+    }
 
 	/**
 	 * Return a new java.sql.ResultSet instance for this implementation.
@@ -631,17 +750,187 @@ public abstract class InternalDriver imp
 	 * @return a new java.sql.ResultSet
 	 * @throws SQLException
 	 */
-	public abstract EmbedResultSet
-		newEmbedResultSet(EmbedConnection conn, ResultSet results, boolean forMetaData, EmbedStatement statement, boolean isAtomic) throws SQLException;
+    public EmbedResultSet newEmbedResultSet(EmbedConnection conn,
+            ResultSet results, boolean forMetaData, EmbedStatement statement,
+            boolean isAtomic) throws SQLException {
+        return new EmbedResultSet(conn, results, forMetaData, statement,
+                isAtomic);
+    }
         
-        /**
-         * Returns a new java.sql.ResultSetMetaData for this implementation
-         *
-         * @param columnInfo a ResultColumnDescriptor that stores information 
-         *        about the columns in a ResultSet
-         */
-        public abstract EmbedResultSetMetaData newEmbedResultSetMetaData
-            (ResultColumnDescriptor[] columnInfo);
+    /**
+     * Returns a new java.sql.ResultSetMetaData for this implementation
+     *
+     * @param columnInfo a ResultColumnDescriptor that stores information
+     *        about the columns in a ResultSet
+     */
+    public EmbedResultSetMetaData newEmbedResultSetMetaData(
+            ResultColumnDescriptor[] columnInfo) {
+        return new EmbedResultSetMetaData(columnInfo);
+    }
+
+    /**
+     * Return a new BrokeredConnection for this implementation.
+     */
+    BrokeredConnection newBrokeredConnection(
+            BrokeredConnectionControl control) throws SQLException {
+        return new BrokeredConnection(control);
+    }
+
+    /**
+     * Create and return an EmbedPooledConnection from the received instance of
+     * EmbeddedDataSource.
+     */
+    protected PooledConnection getNewPooledConnection(
+            EmbeddedBaseDataSource eds, String user, String password,
+            boolean requestPassword) throws SQLException {
+        return new EmbedPooledConnection40(
+                eds, user, password, requestPassword);
+    }
+
+    /**
+     * Create and return an EmbedXAConnection from the received instance of
+     * EmbeddedBaseDataSource.
+     */
+    protected XAConnection getNewXAConnection(
+            EmbeddedBaseDataSource eds, ResourceAdapter ra,
+            String user, String password, boolean requestPassword)
+            throws SQLException {
+        return new EmbedXAConnection40(
+                eds, ra, user, password, requestPassword);
+    }
+
+    private static final String[] BOOLEAN_CHOICES = {"false", "true"};
+
+    /**
+     * <p>The getPropertyInfo method is intended to allow a generic GUI tool to
+     * discover what properties it should prompt a human for in order to get
+     * enough information to connect to a database.  Note that depending on
+     * the values the human has supplied so far, additional values may become
+     * necessary, so it may be necessary to iterate though several calls
+     * to getPropertyInfo.
+     *
+     * @param url The URL of the database to connect to.
+     * @param info A proposed list of tag/value pairs that will be sent on
+     *          connect open.
+     * @return An array of DriverPropertyInfo objects describing possible
+     *          properties.  This array may be an empty array if no properties
+     *          are required.
+     * @exception SQLException if a database-access error occurs.
+     */
+    public DriverPropertyInfo[] getPropertyInfo(String url, Properties info)
+            throws SQLException {
+
+        // RESOLVE other properties should be added into this method in the future ...
+
+        if (info != null) {
+            if (Boolean.valueOf(info.getProperty(Attribute.SHUTDOWN_ATTR)).booleanValue()) {
+
+                // no other options possible when shutdown is set to be true
+                return new DriverPropertyInfo[0];
+            }
+        }
+
+        // at this point we have databaseName,
+
+        String dbname = InternalDriver.getDatabaseName(url, info);
+
+        // convert the ;name=value attributes in the URL into
+        // properties.
+        FormatableProperties finfo = getAttributes(url, info);
+        info = null; // ensure we don't use this reference directly again.
+        boolean encryptDB = Boolean.valueOf(finfo.getProperty(Attribute.DATA_ENCRYPTION)).booleanValue();
+        String encryptpassword = finfo.getProperty(Attribute.BOOT_PASSWORD);
+
+        if (dbname.length() == 0 || (encryptDB && encryptpassword == null)) {
+
+            // with no database name we can have shutdown or a database name
+
+            // In future, if any new attribute info needs to be included in this
+            // method, it just has to be added to either string or boolean or secret array
+            // depending on whether it accepts string or boolean or secret(ie passwords) value.
+
+            String[][] connStringAttributes = {
+                {Attribute.DBNAME_ATTR, MessageId.CONN_DATABASE_IDENTITY},
+                {Attribute.CRYPTO_PROVIDER, MessageId.CONN_CRYPTO_PROVIDER},
+                {Attribute.CRYPTO_ALGORITHM, MessageId.CONN_CRYPTO_ALGORITHM},
+                {Attribute.CRYPTO_KEY_LENGTH, MessageId.CONN_CRYPTO_KEY_LENGTH},
+                {Attribute.CRYPTO_EXTERNAL_KEY, MessageId.CONN_CRYPTO_EXTERNAL_KEY},
+                {Attribute.TERRITORY, MessageId.CONN_LOCALE},
+                {Attribute.COLLATION, MessageId.CONN_COLLATION},
+                {Attribute.USERNAME_ATTR, MessageId.CONN_USERNAME_ATTR},
+                {Attribute.LOG_DEVICE, MessageId.CONN_LOG_DEVICE},
+                {Attribute.ROLL_FORWARD_RECOVERY_FROM, MessageId.CONN_ROLL_FORWARD_RECOVERY_FROM},
+                {Attribute.CREATE_FROM, MessageId.CONN_CREATE_FROM},
+                {Attribute.RESTORE_FROM, MessageId.CONN_RESTORE_FROM},
+            };
+
+            String[][] connBooleanAttributes = {
+                {Attribute.SHUTDOWN_ATTR, MessageId.CONN_SHUT_DOWN_CLOUDSCAPE},
+                {Attribute.DEREGISTER_ATTR, MessageId.CONN_DEREGISTER_AUTOLOADEDDRIVER},
+                {Attribute.CREATE_ATTR, MessageId.CONN_CREATE_DATABASE},
+                {Attribute.DATA_ENCRYPTION, MessageId.CONN_DATA_ENCRYPTION},
+                {Attribute.UPGRADE_ATTR, MessageId.CONN_UPGRADE_DATABASE},
+                };
+
+            String[][] connStringSecretAttributes = {
+                {Attribute.BOOT_PASSWORD, MessageId.CONN_BOOT_PASSWORD},
+                {Attribute.PASSWORD_ATTR, MessageId.CONN_PASSWORD_ATTR},
+                };
+
+
+            DriverPropertyInfo[] optionsNoDB = new  DriverPropertyInfo[connStringAttributes.length+
+                                                                      connBooleanAttributes.length+
+                                                                      connStringSecretAttributes.length];
+
+            int attrIndex = 0;
+            for( int i = 0; i < connStringAttributes.length; i++, attrIndex++ )
+            {
+                optionsNoDB[attrIndex] = new DriverPropertyInfo(connStringAttributes[i][0],
+                                      finfo.getProperty(connStringAttributes[i][0]));
+                optionsNoDB[attrIndex].description = MessageService.getTextMessage(connStringAttributes[i][1]);
+            }
+
+            optionsNoDB[0].choices = Monitor.getMonitor().getServiceList(Property.DATABASE_MODULE);
+            // since database name is not stored in FormatableProperties, we
+            // assign here explicitly
+            optionsNoDB[0].value = dbname;
+
+            for( int i = 0; i < connStringSecretAttributes.length; i++, attrIndex++ )
+            {
+                optionsNoDB[attrIndex] = new DriverPropertyInfo(connStringSecretAttributes[i][0],
+                                      (finfo.getProperty(connStringSecretAttributes[i][0]) == null? "" : "****"));
+                optionsNoDB[attrIndex].description = MessageService.getTextMessage(connStringSecretAttributes[i][1]);
+            }
+
+            for( int i = 0; i < connBooleanAttributes.length; i++, attrIndex++ )
+            {
+                optionsNoDB[attrIndex] = new DriverPropertyInfo(connBooleanAttributes[i][0],
+                    Boolean.valueOf(finfo == null? "" : finfo.getProperty(connBooleanAttributes[i][0])).toString());
+                optionsNoDB[attrIndex].description = MessageService.getTextMessage(connBooleanAttributes[i][1]);
+                optionsNoDB[attrIndex].choices = BOOLEAN_CHOICES;
+            }
+
+            return optionsNoDB;
+        }
+
+        return new DriverPropertyInfo[0];
+    }
+
+    public Connection connect(String url, Properties info) throws SQLException {
+        return connect(url, info, DriverManager.getLoginTimeout());
+    }
+
+    ////////////////////////////////////////////////////////////////////
+    //
+    // INTRODUCED BY JDBC 4.1 IN JAVA 7
+    //
+    ////////////////////////////////////////////////////////////////////
+
+    public Logger getParentLogger()
+            throws SQLFeatureNotSupportedException {
+        throw (SQLFeatureNotSupportedException)
+                Util.notImplemented("getParentLogger()");
+    }
 
     /**
      * Indicate to {@code AutoloadedDriver} whether it should deregister

Modified: db/derby/code/trunk/java/engine/org/apache/derby/modules.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/modules.properties?rev=1494482&r1=1494481&r2=1494482&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/modules.properties (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/modules.properties Wed Jun 19 07:28:36 2013
@@ -169,7 +169,7 @@ cloudscape.config.cryptographyJ2=derby
 
 # jdbc40 - requires JDK 1.6 (which is constant 7 in Derby)
 #
-derby.module.jdbcJ6=org.apache.derby.jdbc.Driver40
+derby.module.jdbcJ6=org.apache.derby.jdbc.InternalDriver
 derby.env.jdk.jdbcJ6=7
 derby.env.classes.jdbcJ6=java.sql.Driver
 cloudscape.config.jdbcJ6=derby

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Driver.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Driver.java?rev=1494482&r1=1494481&r2=1494482&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Driver.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/Wrapper41Driver.java Wed Jun 19 07:28:36 2013
@@ -25,9 +25,9 @@ import java.sql.Driver;
 import java.sql.SQLException;
 import java.util.logging.Logger;
 
-import org.apache.derby.jdbc.AutoloadedDriver40;
+import org.apache.derby.jdbc.AutoloadedDriver;
 import org.apache.derby.jdbc.ClientDriver;
-import org.apache.derby.jdbc.Driver40;
+import org.apache.derby.jdbc.InternalDriver;
 
 /**
  * A wrapper around the methods added by JDBC 4.1.
@@ -42,8 +42,8 @@ public  class   Wrapper41Driver
     //
     ///////////////////////////////////////////////////////////////////////
 
-    private AutoloadedDriver40    _embedded;
-    private Driver40            _driver40;
+    private AutoloadedDriver    _embedded;
+    private InternalDriver      _driver40;
     private ClientDriver      _netclient;
     
     ///////////////////////////////////////////////////////////////////////
@@ -54,8 +54,8 @@ public  class   Wrapper41Driver
 
     public Wrapper41Driver( Object wrapped ) throws Exception
     {
-        if ( wrapped instanceof AutoloadedDriver40 ) { _embedded = (AutoloadedDriver40) wrapped; }
-        else if ( wrapped instanceof Driver40 ) { _driver40 = (Driver40) wrapped; }
+        if ( wrapped instanceof AutoloadedDriver ) { _embedded = (AutoloadedDriver) wrapped; }
+        else if ( wrapped instanceof InternalDriver ) { _driver40 = (InternalDriver) wrapped; }
         else if ( wrapped instanceof ClientDriver ) { _netclient = (ClientDriver) wrapped; }
         else { throw nothingWrapped( wrapped ); }
     }

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=1494482&r1=1494481&r2=1494482&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 Wed Jun 19 07:28:36 2013
@@ -333,8 +333,7 @@ public class AutoloadTest extends BaseJD
     }
     private String  getAutoloadedDriverName()
     {
-        if ( JDBC.vmSupportsJDBC4() ) { return "org.apache.derby.jdbc.AutoloadedDriver40"; }
-        else { return "org.apache.derby.jdbc.AutoloadedDriver"; }
+        return "org.apache.derby.jdbc.AutoloadedDriver";
     }
     private String  getClientDriverName()
     {

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DriverTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DriverTest.java?rev=1494482&r1=1494481&r2=1494482&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DriverTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DriverTest.java Wed Jun 19 07:28:36 2013
@@ -167,15 +167,11 @@ public class DriverTest extends BaseJDBC
         assertEquals(dbmd.getDriverMajorVersion(), driver.getMajorVersion());
         assertEquals(dbmd.getDriverMinorVersion(), driver.getMinorVersion());
 
-        // test that the driver is one of the special 40 versions if we are running
-        // on Java 6 or higher
+        // Test that the driver class is the expected one. Currently, the same
+        // driver class is used regardless of JDBC version.
         println( "Driver is a " + driver.getClass().getName() );
-        if (usingEmbedded()) {
-            assertEquals( JDBC.vmSupportsJDBC4(), driver.getClass().getName().endsWith( "40" ) );
-        } else {
-            // The same client driver class is used regardless of JDBC version.
-            assertEquals("ClientDriver", driver.getClass().getSimpleName());
-        }
+        assertEquals(usingEmbedded() ? "AutoloadedDriver" : "ClientDriver",
+                     driver.getClass().getSimpleName());
 
         // test that null connection URLs raise a SQLException per JDBC 4.2 spec clarification
         try {

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/RollBackWrappingWhenFailOnImportTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/RollBackWrappingWhenFailOnImportTest.java?rev=1494482&r1=1494481&r2=1494482&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/RollBackWrappingWhenFailOnImportTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/RollBackWrappingWhenFailOnImportTest.java Wed Jun 19 07:28:36 2013
@@ -31,7 +31,7 @@ import junit.framework.Test;
 import junit.framework.TestSuite;
 
 import org.apache.derby.impl.jdbc.EmbedConnection;
-import org.apache.derby.jdbc.Driver40;
+import org.apache.derby.jdbc.InternalDriver;
 import org.apache.derbyTesting.junit.BaseJDBCTestCase;
 import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
 import org.apache.derbyTesting.junit.JDBC;
@@ -46,7 +46,7 @@ import org.apache.derbyTesting.junit.Tes
  * 
  */
 public class RollBackWrappingWhenFailOnImportTest extends BaseJDBCTestCase {
-    class MockInternalDriver extends Driver40 {
+    class MockInternalDriver extends InternalDriver {
 
         public class MockConnectionFailWhenRollBack extends EmbedConnection {
 

Modified: db/derby/code/trunk/tools/jar/extraDBMSclasses.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/tools/jar/extraDBMSclasses.properties?rev=1494482&r1=1494481&r2=1494482&view=diff
==============================================================================
--- db/derby/code/trunk/tools/jar/extraDBMSclasses.properties (original)
+++ db/derby/code/trunk/tools/jar/extraDBMSclasses.properties Wed Jun 19 07:28:36 2013
@@ -57,7 +57,6 @@ derby.module.core.csxads.jdk16=org.apach
 derby.module.core.csxads.jdk16n=org.apache.derby.jdbc.BasicEmbeddedXADataSource40
 derby.module.core.cscpds.jdk16=org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource40
 derby.module.core.cscpds.jdk16n=org.apache.derby.jdbc.BasicEmbeddedConnectionPoolDataSource40
-derby.module.core.ad.jdk16=org.apache.derby.jdbc.AutoloadedDriver40
 
 derby.module.database.consistency.checker=org.apache.derby.iapi.db.ConsistencyChecker
 derby.module.database.optimizer.trace=org.apache.derby.iapi.db.OptimizerTrace