Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / MyDerby-10.3 / java / engine / org / apache / derby / jdbc / EmbeddedConnectionPoolDataSource40.java
diff --git a/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource40.java b/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource40.java
new file mode 100644 (file)
index 0000000..62d37b0
--- /dev/null
@@ -0,0 +1,93 @@
+/*\r
\r
+   Derby - Class org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource40\r
\r
+   Licensed to the Apache Software Foundation (ASF) under one or more\r
+   contributor license agreements.  See the NOTICE file distributed with\r
+   this work for additional information regarding copyright ownership.\r
+   The ASF licenses this file to You under the Apache License, Version 2.0\r
+   (the "License"); you may not use this file except in compliance with\r
+   the License.  You may obtain a copy of the License at\r
\r
+      http://www.apache.org/licenses/LICENSE-2.0\r
\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
\r
+ */\r
+package org.apache.derby.jdbc;\r
+\r
+import java.sql.SQLException;\r
+import javax.sql.ConnectionPoolDataSource;\r
+import javax.sql.DataSource;\r
+import javax.sql.PooledConnection;\r
+\r
+import org.apache.derby.impl.jdbc.Util;\r
+import org.apache.derby.iapi.reference.SQLState;\r
+\r
+/** \r
+       EmbeddedConnectionPoolDataSource40 is Derby's ConnectionPoolDataSource\r
+       implementation for the JDBC4.0 environment.\r
+       \r
+\r
+       <P>A ConnectionPoolDataSource is a factory for PooledConnection\r
+       objects. An object that implements this interface will typically be\r
+       registered with a JNDI service.\r
+       <P>\r
+       EmbeddedConnectionPoolDataSource40 supports the JDBC 4.0 specification\r
+       for the J2SE 6.0 Java Virtual Machine environment. Use\r
+       EmbeddedConnectionPoolDataSource if your application runs in the\r
+       following environments:\r
+       <UL>\r
+       <LI> JDBC 3.0 - Java 2 - JDK 1.4, J2SE 5.0\r
+       </UL>   \r
+\r
+       <P>EmbeddedConnectionPoolDataSource40 is serializable and referenceable.\r
+\r
+       <P>See EmbeddedDataSource40 for DataSource properties.\r
+\r
+ */\r
+public class EmbeddedConnectionPoolDataSource40 \r
+                                extends EmbeddedConnectionPoolDataSource \r
+                                implements ConnectionPoolDataSource {    \r
+    \r
+    /**\r
+     * Returns false unless <code>interfaces</code> is implemented \r
+     * \r
+     * @param  interfaces             a Class defining an interface.\r
+     * @return true                   if this implements the interface or \r
+     *                                directly or indirectly wraps an object \r
+     *                                that does.\r
+     * @throws java.sql.SQLException  if an error occurs while determining \r
+     *                                whether this is a wrapper for an object \r
+     *                                with the given interface.\r
+     */\r
+    public boolean isWrapperFor(Class<?> interfaces) throws SQLException {\r
+        return interfaces.isInstance(this);\r
+    }\r
+    \r
+    /**\r
+     * Returns <code>this</code> if this class implements the interface\r
+     *\r
+     * @param  interfaces a Class defining an interface\r
+     * @return an object that implements the interface\r
+     * @throws java.sql.SQLExption if no object if found that implements the \r
+     * interface\r
+     */\r
+    public <T> T unwrap(java.lang.Class<T> interfaces) \r
+                            throws SQLException{\r
+        //Derby does not implement non-standard methods on \r
+        //JDBC objects\r
+        //hence return this if this class implements the interface \r
+        //or throw an SQLException\r
+        try {\r
+            return interfaces.cast(this);\r
+        } catch (ClassCastException cce) {\r
+            throw Util.generateCsSQLException(SQLState.UNABLE_TO_UNWRAP,\r
+                    interfaces);\r
+        }\r
+    }\r
+}\r