db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r1372403 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/jdbc/ engine/org/apache/derby/impl/jdbc/ engine/org/apache/derby/jdbc/ testing/org/apache/derbyTesting/functionTests/tests/jdbc4/
Date Mon, 13 Aug 2012 12:54:04 GMT
Author: kahatlen
Date: Mon Aug 13 12:54:04 2012
New Revision: 1372403

URL: http://svn.apache.org/viewvc?rev=1372403&view=rev
Log:
DERBY-5880: Move java.sql.Wrapper implementations to base classes in embedded driver

Removed:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedParameterMetaData40.java
Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement40.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement40.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement40.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement40.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedParameterMetaData30.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement40.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource40.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource40.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedXADataSource.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedXADataSource40.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/JDBC4FromJDBC3DataSourceTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement40.java?rev=1372403&r1=1372402&r2=1372403&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement40.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredCallableStatement40.java
Mon Aug 13 12:54:04 2012
@@ -175,33 +175,6 @@ public class BrokeredCallableStatement40
         getCallableStatement().setAsciiStream(parameterIndex, x);
     }
 
-    /**
-     * Sets the designated parameter to the given input stream.
-     *
-     * @param parameterIndex the first parameter is 1, the second is 2, ...
-     * @param x the java input stream which contains the binary parameter value
-     * @throws SQLException if a database access error occurs or this method is
-     *      called on a closed <code>PreparedStatement</code>
-     */
-    public final void setBinaryStream(int parameterIndex, InputStream x)
-            throws SQLException {
-        getCallableStatement().setBinaryStream(parameterIndex, x);
-    }
-
-    /**
-     * Sets the designated parameter to the given <code>Reader</code> object.
-     *
-     * @param parameterIndex the first parameter is 1, the second is 2, ...
-     * @param reader the <code>java.io.Reader</code> object that contains the
-     *      Unicode data
-     * @throws SQLException if a database access error occurs or this method is
-     *      called on a closed <code>PreparedStatement</code>
-     */
-    public final void setCharacterStream(int parameterIndex, Reader reader)
-            throws SQLException {
-        getCallableStatement().setCharacterStream(parameterIndex, reader);
-    }
-
     public void setRowId(int parameterIndex, RowId x) throws SQLException{
         getPreparedStatement().setRowId(parameterIndex,x);
     }
@@ -280,25 +253,6 @@ public class BrokeredCallableStatement40
         getPreparedStatement().setSQLXML(parameterIndex,xmlObject);
     }
     
-    /**
-     * Returns <code>this</code> if this class implements the interface
-     *
-     * @param  interfaces a Class defining an interface
-     * @return an object that implements the interface
-     * @throws java.sql.SQLExption if no object if found that implements the 
-     * interface
-     */
-    public <T> T unwrap(java.lang.Class<T> interfaces) 
-                            throws SQLException{
-        checkIfClosed();
-        //Derby does not implement non-standard methods on 
-        //JDBC objects
-        try {
-            return interfaces.cast(this);
-        } catch (ClassCastException cce) {
-            throw unableToUnwrap(interfaces);
-        }
-    }
     /** 
      * Forwards to the real CallableStatement.
      * @return true if the underlying CallableStatement is poolable,

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java?rev=1372403&r1=1372402&r2=1372403&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement.java
Mon Aug 13 12:54:04 2012
@@ -500,6 +500,7 @@ public class BrokeredPreparedStatement e
         getPreparedStatement().setTimestamp( i, x, cal);
     }
     
+    // JDBC 4.0 methods exposed via the EnginePreparedStatement interface
     
     public void setBinaryStream(int parameterIndex, 
                                 InputStream x)

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement40.java?rev=1372403&r1=1372402&r2=1372403&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement40.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredPreparedStatement40.java
Mon Aug 13 12:54:04 2012
@@ -78,26 +78,6 @@ public class BrokeredPreparedStatement40
     public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException{
         getPreparedStatement().setSQLXML (parameterIndex, xmlObject);
     }    
-    
-    /**
-     * Returns <code>this</code> if this class implements the interface
-     *
-     * @param  interfaces a Class defining an interface
-     * @return an object that implements the interface
-     * @throws java.sql.SQLExption if no object if found that implements the 
-     * interface
-     */
-    public <T> T unwrap(java.lang.Class<T> interfaces) 
-                            throws SQLException{
-        checkIfClosed();
-        //Derby does not implement non-standard methods on 
-        //JDBC objects
-        try {
-            return interfaces.cast(this);
-        } catch (ClassCastException cce) {
-            throw unableToUnwrap(interfaces);
-        }
-    }
 
     /** 
      * Forwards to the real PreparedStatement.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java?rev=1372403&r1=1372402&r2=1372403&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement.java Mon
Aug 13 12:54:04 2012
@@ -526,6 +526,8 @@ public class BrokeredStatement implement
 		return control;
 	}
 
+    // JDBC 4.0 java.sql.Wrapper interface methods
+
     /**
      * Returns false unless <code>iface</code> is implemented 
      * 
@@ -543,6 +545,24 @@ public class BrokeredStatement implement
     }
 
     /**
+     * Returns {@code this} if this class implements the specified interface.
+     *
+     * @param iface a class defining an interface
+     * @return an object that implements the interface
+     * @throws SQLException if no object is found that implements the
+     * interface
+     */
+    public <T> T unwrap(Class<T> iface) throws SQLException {
+        checkIfClosed();
+        // Derby does not implement non-standard methods on JDBC objects.
+        try {
+            return iface.cast(this);
+        } catch (ClassCastException cce) {
+            throw unableToUnwrap(iface);
+        }
+    }
+
+    /**
      * Checks if the statement is closed.
      *
      * @return <code>true</code> if the statement is closed,

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement40.java?rev=1372403&r1=1372402&r2=1372403&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/BrokeredStatement40.java Mon
Aug 13 12:54:04 2012
@@ -36,26 +36,6 @@ public class BrokeredStatement40 extends
                                                     throws SQLException {
         super(control);
     }
-    
-    /**
-     * Returns <code>this</code> if this class implements the interface
-     *
-     * @param  interfaces a Class defining an interface
-     * @return an object that implements the interface
-     * @throws java.sql.SQLExption if no object if found that implements the 
-     * interface
-     */
-    public <T> T unwrap(java.lang.Class<T> interfaces) 
-                            throws SQLException {
-        checkIfClosed();
-        //Derby does not implement non-standard methods on 
-        //JDBC objects
-        try {
-            return interfaces.cast(this);
-        } catch (ClassCastException cce) {
-            throw unableToUnwrap(interfaces);
-        }
-    }
 
     /** 
      * Forwards to the real Statement.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement40.java?rev=1372403&r1=1372402&r2=1372403&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement40.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedCallableStatement40.java
Mon Aug 13 12:54:04 2012
@@ -28,13 +28,11 @@ import java.sql.Blob;
 import java.sql.Clob;
 import java.sql.Date;
 import java.sql.NClob;
-import java.sql.ParameterMetaData;
 import java.sql.RowId;
 import java.sql.SQLException;
 import java.sql.SQLXML;
 import java.sql.Time;
 import java.sql.Timestamp;
-
 import org.apache.derby.iapi.jdbc.EngineCallableStatement40;
 import org.apache.derby.iapi.reference.SQLState;
 
@@ -195,25 +193,6 @@ public class EmbedCallableStatement40
     }  
     
     /**
-    * JDBC 4.0
-    *
-    * Retrieves the number, types and properties of this CallableStatement
-    * object's parameters.
-    *
-    * @return a ParameterMetaData object that contains information about the
-    * number, types and properties of this CallableStatement object's parameters.
-    * @exception SQLException if a database access error occurs
-    *
-    */
-    public ParameterMetaData getParameterMetaData()
-        throws SQLException
-    {
-	  checkStatus();
-	  return new EmbedParameterMetaData40(
-				getParms(), preparedStatement.getParameterTypes());
-    }
-    
-    /**
      * Returns false unless <code>interfaces</code> is implemented 
      * 
      * @param  interfaces             a Class defining an interface.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedParameterMetaData30.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedParameterMetaData30.java?rev=1372403&r1=1372402&r2=1372403&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedParameterMetaData30.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedParameterMetaData30.java
Mon Aug 13 12:54:04 2012
@@ -21,13 +21,14 @@
 
 package org.apache.derby.impl.jdbc;
 
+import java.sql.ParameterMetaData;
+import java.sql.SQLException;
+import org.apache.derby.iapi.reference.SQLState;
 import org.apache.derby.iapi.sql.ParameterValueSet;
 import org.apache.derby.iapi.types.DataTypeDescriptor;
 
-import java.sql.ParameterMetaData;
-
 /**
- * This class implements the ParameterMetaData interface from JDBC3.0
+ * This class implements the ParameterMetaData interface from JDBC 3.0 and 4.0.
  * It provides the parameter meta data for callable & prepared statements
  * But note that the bulk of it resides in its parent class.  The reason is
  * we want to provide the functionality to the JDKs before JDBC3.0.
@@ -35,6 +36,7 @@ import java.sql.ParameterMetaData;
   <P><B>Supports</B>
    <UL>
    <LI> JDBC 3.0 - java.sql.ParameterMetaData introduced in JDBC3
+   <LI> JDBC 4.0 - extra methods from java.sql.Wrapper introduced in JDBC 4.0
    </UL>
 
  * @see java.sql.ParameterMetaData
@@ -52,5 +54,36 @@ class EmbedParameterMetaData30 extends o
 		super(pvs, types);
     }
 
-}
+    /**
+     * Returns false unless {@code iface}</code> is implemented.
+     *
+     * @param iface a class defining an interface
+     * @return true if this implements the interface or directly or indirectly
+     * wraps an object that does
+     * @throws SQLException if an error occurs while determining
+     * whether this is a wrapper for an object with the given interface.
+     */
+    public boolean isWrapperFor(Class<?> iface) throws SQLException {
+        return iface.isInstance(this);
+    }
 
+    /**
+     * Returns {@code this} if this class implements the specified interface.
+     *
+     * @param iface a class defining an interface
+     * @return an object that implements the interface
+     * @throws SQLException if no object is found that implements the
+     * interface
+     */
+    public <T> T unwrap(Class<T> iface) throws SQLException {
+        // Derby does not implement non-standard methods on JDBC objects,
+        // hence return this if this class implements the interface, or
+        // throw an SQLException.
+        try {
+            return iface.cast(this);
+        } catch (ClassCastException cce) {
+            throw Util.generateCsSQLException(SQLState.UNABLE_TO_UNWRAP,
+                    iface);
+        }
+    }
+}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement40.java?rev=1372403&r1=1372402&r2=1372403&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement40.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement40.java
Mon Aug 13 12:54:04 2012
@@ -76,25 +76,6 @@ public class EmbedPreparedStatement40 ex
         throw Util.notImplemented();
     }
     
-   /**
-    * JDBC 4.0
-    *
-    * Retrieves the number, types and properties of this PreparedStatement
-    * object's parameters.
-    *
-    * @return a ParameterMetaData object that contains information about the
-    * number, types and properties of this PreparedStatement object's parameters.
-    * @exception SQLException if a database access error occurs
-    *
-    */
-    public ParameterMetaData getParameterMetaData()
-        throws SQLException
-    {
-	  checkStatus();
-	  return new EmbedParameterMetaData40(
-				getParms(), preparedStatement.getParameterTypes());
-    }
-    
     /**
      * Returns false unless <code>interfaces</code> is implemented 
      * 

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=1372403&r1=1372402&r2=1372403&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
Mon Aug 13 12:54:04 2012
@@ -22,14 +22,11 @@
 package org.apache.derby.jdbc;
 
 import java.sql.SQLException;
-
-/* -- New jdbc 20 extension types --- */
-import javax.sql.ConnectionPoolDataSource;
 import javax.sql.PooledConnection;
 
 /** 
 	EmbeddedConnectionPoolDataSource is Derby's ConnectionPoolDataSource
-	implementation for the JDBC3.0 environment.
+	implementation for JDBC 3.0 and JDBC 4.0.
 	
 
 	<P>A ConnectionPoolDataSource is a factory for PooledConnection
@@ -39,7 +36,8 @@ import javax.sql.PooledConnection;
 	EmbeddedConnectionPoolDataSource automatically supports the correct JDBC specification version
 	for the Java Virtual Machine's environment.
 	<UL>
-	<LI> JDBC 3.0 - Java 2 - JDK 1.4, J2SE 5.0
+    <LI> JDBC 3.0 - J2SE 5.0 </LI>
+    <LI> JDBC 4.0 - Java SE 6 </LI>
 	</UL>
 
 	<P>EmbeddedConnectionPoolDataSource is serializable and referenceable.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource40.java?rev=1372403&r1=1372402&r2=1372403&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource40.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource40.java
Mon Aug 13 12:54:04 2012
@@ -20,31 +20,28 @@
  */
 package org.apache.derby.jdbc;
 
-import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
 import java.util.logging.Logger;
 import javax.sql.ConnectionPoolDataSource;
-import javax.sql.DataSource;
-import javax.sql.PooledConnection;
-
 import org.apache.derby.impl.jdbc.Util;
-import org.apache.derby.iapi.reference.SQLState;
 
 /** 
 	EmbeddedConnectionPoolDataSource40 is Derby's ConnectionPoolDataSource
-	implementation for JDBC 4.0 (and higher) environments.
+    implementation for JDBC 4.1 (and higher) environments.
 	
 
 	<P>A ConnectionPoolDataSource is a factory for PooledConnection
 	objects. An object that implements this interface will typically be
 	registered with a JNDI service.
 	<P>
-	Use EmbeddedConnectionPoolDataSource40 if your application runs at JDBC level 4.0 (or higher).
+    Use EmbeddedConnectionPoolDataSource40 if your application runs at JDBC
+    level 4.1 (or higher).
 	Use
 	EmbeddedConnectionPoolDataSource if your application runs in the
 	following environments:
 	<UL>
-	<LI> JDBC 3.0 - Java 2 - JDK 1.4, J2SE 5.0
+    <LI> JDBC 3.0 - J2SE 5.0 </LI>
+    <LI> JDBC 4.0 - Java SE 6 </LI>
 	</UL>	
 
 	<P>EmbeddedConnectionPoolDataSource40 is serializable and referenceable.
@@ -56,43 +53,6 @@ public class EmbeddedConnectionPoolDataS
                                 extends EmbeddedConnectionPoolDataSource 
                                 implements ConnectionPoolDataSource {    
     
-    /**
-     * Returns false unless <code>interfaces</code> is implemented 
-     * 
-     * @param  interfaces             a Class defining an interface.
-     * @return true                   if this implements the interface or 
-     *                                directly or indirectly wraps an object 
-     *                                that does.
-     * @throws java.sql.SQLException  if an error occurs while determining 
-     *                                whether this is a wrapper for an object 
-     *                                with the given interface.
-     */
-    public boolean isWrapperFor(Class<?> interfaces) throws SQLException {
-        return interfaces.isInstance(this);
-    }
-    
-    /**
-     * Returns <code>this</code> if this class implements the interface
-     *
-     * @param  interfaces a Class defining an interface
-     * @return an object that implements the interface
-     * @throws java.sql.SQLExption if no object if found that implements the 
-     * interface
-     */
-    public <T> T unwrap(java.lang.Class<T> interfaces) 
-                            throws SQLException{
-        //Derby does not implement non-standard methods on 
-        //JDBC objects
-        //hence return this if this class implements the interface 
-        //or throw an SQLException
-        try {
-            return interfaces.cast(this);
-        } catch (ClassCastException cce) {
-            throw Util.generateCsSQLException(SQLState.UNABLE_TO_UNWRAP,
-                    interfaces);
-        }
-    }
-   
     ////////////////////////////////////////////////////////////////////
     //
     // INTRODUCED BY JDBC 4.1 IN JAVA 7

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource.java?rev=1372403&r1=1372402&r2=1372403&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource.java Mon Aug
13 12:54:04 2012
@@ -21,32 +21,20 @@
 
 package org.apache.derby.jdbc;
 
-import org.apache.derby.iapi.reference.Attribute;
-
+import java.io.PrintWriter;
 import java.sql.Connection;
 import java.sql.Driver;
 import java.sql.DriverManager;
 import java.sql.SQLException;
-
-import java.io.PrintWriter;
 import java.util.Properties;
-
-/* -- New jdbc 20 extension types --- */
-import javax.sql.DataSource;
-
-
 import org.apache.derby.iapi.reference.Attribute;
-import org.apache.derby.iapi.reference.MessageId;
 import org.apache.derby.iapi.reference.SQLState;
-import org.apache.derby.iapi.error.ExceptionSeverity;
-import org.apache.derby.iapi.services.i18n.MessageService;
 import org.apache.derby.impl.jdbc.Util;
 
 /** 
-	
 
-	EmbeddedDataSource is Derby's DataSource implementation for JDBC3.0.
-	
+    EmbeddedDataSource is Derby's DataSource implementation for JDBC 3.0
+    and JDBC 4.0.
 
 	<P>A DataSource  is a factory for Connection objects. An object that
 	implements the DataSource interface will typically be registered with a
@@ -55,7 +43,8 @@ import org.apache.derby.impl.jdbc.Util;
 	EmbeddedDataSource automatically supports the correct JDBC specification version
 	for the Java Virtual Machine's environment.
 	<UL>
-	<LI> JDBC 3.0 - Java 2 - JDK 1.4, J2SE 5.0
+    <LI> JDBC 3.0 - J2SE 5.0 </LI>
+    <LI> JDBC 4.0 - Java SE 6 </LI>
 	</UL>
 
 	<P>The following is a list of properties that can be set on a Derby
@@ -486,7 +475,42 @@ public class EmbeddedDataSource extends 
 
         return conn;
 	}
-   
+
+    // JDBC 4.0 java.sql.Wrapper interface methods
+
+    /**
+     * Returns false unless {@code interfaces} is implemented.
+     *
+     * @param iface a class defining an interface
+     * @return true if this implements the interface or directly or indirectly
+     * wraps an object that does
+     * @throws SQLException if an error occurs while determining
+     * whether this is a wrapper for an object with the given interface
+     */
+    public boolean isWrapperFor(Class<?> iface) throws SQLException {
+        return iface.isInstance(this);
+    }
+
+    /**
+     * Returns {@code this} if this class implements the specified interface.
+     *
+     * @param iface a class defining an interface
+     * @return an object that implements the interface
+     * @throws SQLException if no object is found that implements the
+     * interface
+     */
+    public <T> T unwrap(Class<T> iface) throws SQLException {
+        // Derby does not implement non-standard methods on JDBC objects,
+        // hence return this if this class implements the interface, or
+        // throw an SQLException.
+        try {
+            return iface.cast(this);
+        } catch (ClassCastException cce) {
+            throw Util.generateCsSQLException(SQLState.UNABLE_TO_UNWRAP,
+                    iface);
+        }
+    }
+
 	InternalDriver findDriver() throws SQLException
 	{
 		String url = jdbcurl;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource40.java?rev=1372403&r1=1372402&r2=1372403&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource40.java Mon Aug
13 12:54:04 2012
@@ -21,30 +21,26 @@
 
 package org.apache.derby.jdbc;
 
-import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
 import java.util.logging.Logger;
-import javax.sql.DataSource;
-
 import org.apache.derby.impl.jdbc.Util;
-import org.apache.derby.iapi.reference.SQLState;
 
 /** 
-	
 
-	EmbeddedDataSource40 is Derby's DataSource implementation for JDBC 4.0 (and higher).
-	
+	EmbeddedDataSource40 is Derby's DataSource implementation for JDBC 4.1.
 
 	<P>A DataSource  is a factory for Connection objects. An object that
 	implements the DataSource interface will typically be registered with a
 	JNDI service provider.
 	<P>
-	Use EmbeddedDataSource40 if your application runs at JDBC level 4.0 (or higher).
+    Use EmbeddedDataSource40 if your application runs at JDBC level 4.1
+    (or higher).
 	Use EmbeddedDataSource
 	if your application is runs in one of the following older
 	environments:
 	<UL>
-	<LI> JDBC 3.0 - Java 2 - JDK 1.4, J2SE 5.0
+    <LI> JDBC 3.0 - J2SE 5.0 </LI>
+    <LI> JDBC 4.0 - Java SE 6 </LI>
 	</UL>	
 
 	<P>The following is a list of properties that can be set on a Derby
@@ -184,44 +180,7 @@ public class EmbeddedDataSource40 extend
     
     public EmbeddedDataSource40() {
     }
-       
-    /**
-     * Returns false unless <code>interfaces</code> is implemented 
-     * 
-     * @param  interfaces             a Class defining an interface.
-     * @return true                   if this implements the interface or 
-     *                                directly or indirectly wraps an object 
-     *                                that does.
-     * @throws java.sql.SQLException  if an error occurs while determining 
-     *                                whether this is a wrapper for an object 
-     *                                with the given interface.
-     */
-    public boolean isWrapperFor(Class<?> interfaces) throws SQLException {
-        return interfaces.isInstance(this);
-    }
-    
-    /**
-     * Returns <code>this</code> if this class implements the interface
-     *
-     * @param  interfaces a Class defining an interface
-     * @return an object that implements the interface
-     * @throws java.sql.SQLExption if no object if found that implements the 
-     * interface
-     */
-    public <T> T unwrap(java.lang.Class<T> interfaces) 
-                            throws SQLException{
-        //Derby does not implement non-standard methods on 
-        //JDBC objects
-        //hence return this if this class implements the interface 
-        //or throw an SQLException
-        try {
-            return interfaces.cast(this);
-        } catch (ClassCastException cce) {
-            throw Util.generateCsSQLException(SQLState.UNABLE_TO_UNWRAP,
-                    interfaces);
-        }
-    }
-    
+
     ////////////////////////////////////////////////////////////////////
     //
     // INTRODUCED BY JDBC 4.1 IN JAVA 7

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=1372403&r1=1372402&r2=1372403&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 Mon Aug
13 12:54:04 2012
@@ -21,31 +21,20 @@
 
 package org.apache.derby.jdbc;
 
+import java.sql.SQLException;
+import javax.sql.XAConnection;
+import org.apache.derby.iapi.db.Database;
+import org.apache.derby.iapi.error.ExceptionSeverity;
+import org.apache.derby.iapi.jdbc.ResourceAdapter;
 import org.apache.derby.iapi.reference.MessageId;
+import org.apache.derby.iapi.reference.Property;
 import org.apache.derby.iapi.services.i18n.MessageService;
-
 import org.apache.derby.iapi.services.monitor.Monitor;
-import org.apache.derby.iapi.jdbc.ResourceAdapter;
-import org.apache.derby.iapi.db.Database;
-
-import org.apache.derby.iapi.reference.Property;
-
-import org.apache.derby.iapi.error.ExceptionSeverity;
-
-import java.sql.SQLException;
-import java.sql.Connection;
-import java.sql.Driver;
-
-
-/** -- jdbc 2.0. extension -- */
-import javax.sql.XADataSource;
-import javax.sql.XAConnection;
-
 
 /**
 
-	EmbeddedXADataSource is Derby's XADataSource implementation for JDBC3.0.
-	
+    EmbeddedXADataSource is Derby's XADataSource implementation for JDBC 3.0
+    and JDBC 4.0.
 
 	<P>An XADataSource is a factory for XAConnection objects.  It represents a
 	RM in a DTP environment.  An object that implements the XADataSource
@@ -54,7 +43,8 @@ import javax.sql.XAConnection;
 	EmbeddedXADataSource automatically supports the correct JDBC specification version
 	for the Java Virtual Machine's environment.
 	<UL>
-	<LI> JDBC 3.0 - Java 2 - JDK 1.4, J2SE 5.0
+    <LI> JDBC 3.0 - J2SE 5.0 </LI>
+    <LI> JDBC 4.0 - Java SE 6 </LI>
 	</UL>
 
 	<P>EmbeddedXADataSource object only works on a local database.  There is no

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedXADataSource40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedXADataSource40.java?rev=1372403&r1=1372402&r2=1372403&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedXADataSource40.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedXADataSource40.java Mon
Aug 13 12:54:04 2012
@@ -21,32 +21,26 @@
 
 package org.apache.derby.jdbc;
 
-import org.apache.derby.iapi.jdbc.ResourceAdapter;
-
-import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
 import java.util.logging.Logger;
-import javax.sql.DataSource;
-import javax.sql.XAConnection;
-import javax.sql.XADataSource;
-
 import org.apache.derby.impl.jdbc.Util;
-import org.apache.derby.iapi.reference.SQLState;
 
 /**
 
-	EmbeddedXADataSource40 is Derby's XADataSource implementation for JDBC 4.0 (and higher).
-	
+    EmbeddedXADataSource40 is Derby's XADataSource implementation for
+    JDBC 4.1 (and higher).
 
 	<P>An XADataSource is a factory for XAConnection objects.  It represents a
 	RM in a DTP environment.  An object that implements the XADataSource
 	interface is typically registered with a JNDI service provider.   	
 	<P>
-	Use EmbeddedXADataSource40 if your application runs at JDBC level 4.0 (or higher).
+    Use EmbeddedXADataSource40 if your application runs at JDBC level 4.1
+    (or higher).
 	Use EmbeddedXADataSource
 	if your application runs in the following environments:
 	<UL>
-	<LI> JDBC 3.0 - Java 2 - JDK 1.4, J2SE 5.0
+    <LI> JDBC 3.0 - J2SE 5.0 </LI>
+    <LI> JDBC 4.0 - Java SE 6 </LI>
 	</UL>
 
 	<P>EmbeddedXADataSource40 object only works on a local database.  There is no
@@ -63,43 +57,6 @@ public class EmbeddedXADataSource40 exte
     public EmbeddedXADataSource40() {
         super();
     }
-        
-    /**
-     * Returns false unless <code>interfaces</code> is implemented 
-     * 
-     * @param  interfaces             a Class defining an interface.
-     * @return true                   if this implements the interface or 
-     *                                directly or indirectly wraps an object 
-     *                                that does.
-     * @throws java.sql.SQLException  if an error occurs while determining 
-     *                                whether this is a wrapper for an object 
-     *                                with the given interface.
-     */
-    public boolean isWrapperFor(Class<?> interfaces) throws SQLException {
-        return interfaces.isInstance(this);
-    }
-    
-    /**
-     * Returns <code>this</code> if this class implements the interface
-     *
-     * @param  interfaces a Class defining an interface
-     * @return an object that implements the interface
-     * @throws java.sql.SQLExption if no object if found that implements the 
-     * interface
-     */
-    public <T> T unwrap(java.lang.Class<T> interfaces) 
-                            throws SQLException{
-        //Derby does not implement non-standard methods on 
-        //JDBC objects
-        //hence return this if this class implements the interface 
-        //or throw an SQLException
-        try {
-            return interfaces.cast(this);
-        } catch (ClassCastException cce) {
-            throw Util.generateCsSQLException(SQLState.UNABLE_TO_UNWRAP,
-                    interfaces);
-        }
-    }
     
     ////////////////////////////////////////////////////////////////////
     //

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/JDBC4FromJDBC3DataSourceTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/JDBC4FromJDBC3DataSourceTest.java?rev=1372403&r1=1372402&r2=1372403&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/JDBC4FromJDBC3DataSourceTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/JDBC4FromJDBC3DataSourceTest.java
Mon Aug 13 12:54:04 2012
@@ -21,24 +21,20 @@
 
 package org.apache.derbyTesting.functionTests.tests.jdbc4;
 
-import junit.framework.*;
-
-import org.apache.derbyTesting.junit.BaseJDBCTestCase;
-import org.apache.derbyTesting.junit.J2EEDataSource;
-import org.apache.derbyTesting.junit.JDBC;
-import org.apache.derbyTesting.junit.JDBCClient;
-import org.apache.derbyTesting.junit.JDBCDataSource;
-import org.apache.derbyTesting.junit.TestConfiguration;
-
+import java.lang.reflect.InvocationTargetException;
 import java.sql.Connection;
 import java.sql.SQLException;
-
 import javax.sql.ConnectionPoolDataSource;
 import javax.sql.DataSource;
 import javax.sql.PooledConnection;
 import javax.sql.StatementEvent;
 import javax.sql.StatementEventListener;
 import javax.sql.XADataSource;
+import junit.framework.*;
+import org.apache.derbyTesting.junit.BaseJDBCTestCase;
+import org.apache.derbyTesting.junit.J2EEDataSource;
+import org.apache.derbyTesting.junit.JDBC;
+import org.apache.derbyTesting.junit.TestConfiguration;
 
 /**
  * <p>
@@ -48,9 +44,8 @@ import javax.sql.XADataSource;
  * </p>
  *
  * <p>
- * Note that after DERBY-5868, all the data sources on the client implement
- * all JDBC 4.0 methods. On embedded, the JDBC 3 variants of the data sources
- * still don't implement the full JDBC 4.0 interface.
+ * Note that after DERBY-5868 and DERBY-5880, all the data sources (except
+ * EmbeddedSimpleDataSource for JSR-169) implement all JDBC 4.0 methods.
  * </p>
  *
  * <p>
@@ -118,24 +113,24 @@ public class JDBC4FromJDBC3DataSourceTes
     private void assertNonJDBC4DataSource(DataSource ds)
         throws SQLException
     {
-        // After DERBY-5868, however, all the data sources on the client
-        // driver implement the JDBC 4.0 interface, so expect this check
-        // to pass.
-        if (usingDerbyNetClient()) {
-            assertTrue(ds.isWrapperFor(DataSource.class));
-            return;
-        }
-
-        /* Simplest way is to try to call a JDBC 4 interface method;
-         * if it succeeds, then we must have a JDBC 4 data source
-         * (which we don't want).
-         */
+        // See if we can invoke the JDBC 4.1 getParentLogger() method. If we
+        // can, we have a JDBC 4 data source.
         try {
-
-            ds.isWrapperFor(DataSource.class);
-            fail("Found JDBC 4 data source when JDBC 3 was expected.");
-
-        } catch (java.lang.AbstractMethodError ame) {}
+            ds.getClass().getMethod("getParentLogger").invoke(ds);
+            fail("Call to getParentLogger() not expected to pass");
+        } catch (NoSuchMethodException nsme) {
+            // OK. Method not found is expected on Java 6.
+        } catch (InvocationTargetException ite) {
+            // On Java 7 and newer the method is found in the CommonDataSource
+            // interface, so expect an AbstractMethodError instead of
+            // NoSuchMethodException.
+            Throwable cause = ite.getCause();
+            if (!(cause instanceof AbstractMethodError)) {
+                fail("Unexpected exception", cause);
+            }
+        } catch (IllegalAccessException iae) {
+            fail("Unexpected exception", iae);
+        }
     }
 
     /**



Mime
View raw message