db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r408772 - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/LogicalConnection40.java engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource40.java engine/org/apache/derby/jdbc/EmbeddedXADataSource40.java
Date Mon, 22 May 2006 22:19:10 GMT
Author: rhillegas
Date: Mon May 22 15:19:08 2006
New Revision: 408772

URL: http://svn.apache.org/viewvc?rev=408772&view=rev
Log:
DERBY-1253: Commit bug1253_forwarding.diff. This forwards some miscellaneous JDBC4 calls to
competent objects.

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection40.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource40.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedXADataSource40.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection40.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection40.java?rev=408772&r1=408771&r2=408772&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection40.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/LogicalConnection40.java Mon
May 22 15:19:08 2006
@@ -54,37 +54,44 @@
 
     public Array createArray(String typeName, Object[] elements)
         throws SQLException {
-        throw SQLExceptionFactory.notImplemented("createArray(String,Object[])");
+		checkForNullPhysicalConnection();
+        return physicalConnection_.createArray( typeName, elements );
     }
     
     public Blob createBlob()
         throws SQLException {
-        throw SQLExceptionFactory.notImplemented("createBlob()");
+		checkForNullPhysicalConnection();
+        return physicalConnection_.createBlob();
     }
 
     public Clob createClob()
         throws SQLException {
-        throw SQLExceptionFactory.notImplemented("createClob()");
+		checkForNullPhysicalConnection();
+        return physicalConnection_.createClob();
     }
     
     public NClob createNClob()
         throws SQLException {
-        throw SQLExceptionFactory.notImplemented("createNClob()");
+		checkForNullPhysicalConnection();
+        return physicalConnection_.createNClob();
     }
 
     public <T extends BaseQuery>T createQueryObject(Class<T> ifc)
         throws SQLException {
-        throw SQLExceptionFactory.notImplemented("createQueryObject(Class<T>)");
+		checkForNullPhysicalConnection();
+		return physicalConnection_.createQueryObject( ifc );
     }
     
     public SQLXML createSQLXML()
         throws SQLException {
-        throw SQLExceptionFactory.notImplemented("createSQLXML()");
+		checkForNullPhysicalConnection();
+        return physicalConnection_.createSQLXML();
     }
 
     public Struct createStruct(String typeName, Object[] attributes)
         throws SQLException {
-        throw SQLExceptionFactory.notImplemented("createStruct(String,Object[])");
+		checkForNullPhysicalConnection();
+        return physicalConnection_.createStruct( typeName, attributes );
     }
 
     /**

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=408772&r1=408771&r2=408772&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 May 22 15:19:08 2006
@@ -26,6 +26,9 @@
 import javax.sql.ConnectionPoolDataSource;
 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 the JDBC4.0 environment.
@@ -53,6 +56,43 @@
                                 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);
+        }
+    }
+
     /**
      * returns null indicating that no driver specific implementation for 
      * QueryObjectGenerator available

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=408772&r1=408771&r2=408772&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
May 22 15:19:08 2006
@@ -29,6 +29,9 @@
 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 JDBC4.0.
@@ -61,6 +64,43 @@
         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);
+        }
+    }
+	
     /**
      * returns null indicating that no driver specific implementation for 
      * QueryObjectGenerator available



Mime
View raw message