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 rh...@apache.org on 2006/04/13 14:50:57 UTC

svn commit: r393791 - in /db/derby/code/trunk: java/engine/org/apache/derby/jdbc/ java/tools/org/apache/derby/impl/tools/ij/ tools/jar/

Author: rhillegas
Date: Thu Apr 13 05:49:57 2006
New Revision: 393791

URL: http://svn.apache.org/viewcvs?rev=393791&view=rev
Log:
Commit Anurag's derby-1137_4.diff patch to DERBY-1137: implement new JDBC4 CommonDataSource methods.

Added:
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource40.java   (with props)
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedXADataSource40.java   (with props)
Modified:
    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/tools/org/apache/derby/impl/tools/ij/xaHelper.java
    db/derby/code/trunk/tools/jar/extraDBMSclasses.properties

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource.java?rev=393791&r1=393790&r2=393791&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 Thu Apr 13 05:49:57 2006
@@ -71,7 +71,7 @@
 		@exception SQLException if a database-access error occurs.
 	*/
 	public final PooledConnection getPooledConnection() throws SQLException { 
-		return new EmbedPooledConnection(this, getUser(), getPassword(), false);
+		return createPooledConnection (getUser(), getPassword(), false);
 	}
 
 	/**
@@ -88,9 +88,20 @@
 												String password)
 		 throws SQLException
 	{
-		return new EmbedPooledConnection(this, username, password, true);
+		return createPooledConnection (username, password, true);
 	}
-
+        
+    /**
+     * create and returns EmbedPooledConnection.
+     * @param user 
+     * @param password 
+     * @param requestPAssword 
+     * @return 
+     */
+        protected PooledConnection createPooledConnection (String user, 
+                String password, boolean requestPAssword) throws SQLException {
+            return new EmbedPooledConnection(this, user, password, true);
+        }
 }
 
 

Added: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource40.java?rev=393791&view=auto
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource40.java (added)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource40.java Thu Apr 13 05:49:57 2006
@@ -0,0 +1,71 @@
+/*
+ 
+   Derby - Class org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource40
+ 
+   Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ 
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+ 
+      http://www.apache.org/licenses/LICENSE-2.0
+ 
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ 
+ */
+package org.apache.derby.jdbc;
+
+import java.sql.BaseQuery;
+import java.sql.QueryObjectFactory;
+import java.sql.QueryObjectGenerator;
+import java.sql.SQLException;
+import javax.sql.ConnectionPoolDataSource;
+import javax.sql.PooledConnection;
+
+/**
+ * This class is meant to be used while running the applications with jdbc4.0
+ * support. It extends EmbeddedDataSource40 which implements jdbc 4.0 
+ * specific methods.
+ */
+
+public class EmbeddedConnectionPoolDataSource40 
+                                extends EmbeddedConnectionPoolDataSource 
+                                implements ConnectionPoolDataSource {    
+    
+    /**
+     * returns null indicating that no driver specific implementation for 
+     * QueryObjectGenerator available
+     * @return null
+     */
+    public QueryObjectGenerator getQueryObjectGenerator() throws SQLException {
+        return null;
+    }
+    
+    /**
+     * This method forwards all the calls to default query object provided by 
+     * the jdk.
+     * @param ifc interface to generated concreate class
+     * @return concreat class generated by default qury object generator
+     */
+    public <T extends BaseQuery> T createQueryObject(Class<T> ifc) 
+                                                    throws SQLException {
+        return QueryObjectFactory.createDefaultQueryObject (ifc, this);
+    }
+    
+    /**
+     * create and returns EmbedPooledConnection.
+     * @param user 
+     * @param password 
+     * @param requestPAssword 
+     * @return 
+     */
+    protected PooledConnection createPooledConnection (String user, 
+            String password, boolean requestPAssword)  throws SQLException {
+        return new EmbedPooledConnection40 (this, user, password, true);
+    }    
+        
+}

Propchange: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedConnectionPoolDataSource40.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedXADataSource.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedXADataSource.java?rev=393791&r1=393790&r2=393791&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 Thu Apr 13 05:49:57 2006
@@ -100,7 +100,7 @@
 		if (ra == null || !ra.isActive())
 			setupResourceAdapter(null, null, false);
 
-		return new EmbedXAConnection(this, ra, getUser(), getPassword(), false);
+		return createXAConnection (ra, getUser(), getPassword(), false);
 	}
 
 	/**
@@ -117,8 +117,7 @@
 	{
 		if (ra == null || !ra.isActive())
 			setupResourceAdapter(user, password, true);
-
-		return new EmbedXAConnection(this, ra, user, password, true);
+                return createXAConnection (ra, user, password, true);
 	}
 	
 	/*
@@ -189,4 +188,17 @@
 			}
 		}
 	}
+        
+    /**
+     * Intantiate and returns EmbedXAConnection.
+     * @param user 
+     * @param password 
+     * @return XAConnection
+     */
+        protected XAConnection createXAConnection (ResourceAdapter ra, 
+                String user, String password, 
+                boolean requestPassword) throws SQLException {
+            return new EmbedXAConnection(this, ra, user, 
+                    password, requestPassword);
+        }
 }

Added: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedXADataSource40.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedXADataSource40.java?rev=393791&view=auto
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedXADataSource40.java (added)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedXADataSource40.java Thu Apr 13 05:49:57 2006
@@ -0,0 +1,75 @@
+/*
+ 
+   Derby - Class org.apache.derby.jdbc.EmbeddedXADataSource40
+ 
+   Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ 
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+ 
+      http://www.apache.org/licenses/LICENSE-2.0
+ 
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+ 
+ */
+
+package org.apache.derby.jdbc;
+
+import java.sql.BaseQuery;
+import java.sql.QueryObjectFactory;
+import java.sql.QueryObjectGenerator;
+import org.apache.derby.iapi.jdbc.ResourceAdapter;
+
+import java.sql.SQLException;
+import javax.sql.XAConnection;
+import javax.sql.XADataSource;
+
+/**
+ * This class is JDBC4.0 implementation of XADataSource
+ * This class extends from  EmbeddedDataSource40 so it inherits the
+ * new method introduced in ConnectionPoolDataSource from EmbeddedDataSource40
+ */
+public class EmbeddedXADataSource40 extends EmbeddedXADataSource {
+    /** Creates a new instance of EmbeddedXADataSource40 */
+    public EmbeddedXADataSource40() {
+        super();
+    }
+        
+    /**
+     * returns null indicating that no driver specific implementation for 
+     * QueryObjectGenerator available
+     * @return null
+     */
+    public QueryObjectGenerator getQueryObjectGenerator() throws SQLException {
+        return null;
+    }
+    
+    /**
+     * This method forwards all the calls to default query object provided by 
+     * the jdk.
+     * @param ifc interface to generated concreate class
+     * @return concreat class generated by default qury object generator
+     */
+    public <T extends BaseQuery> T createQueryObject(Class<T> ifc) 
+                                                    throws SQLException {
+        return QueryObjectFactory.createDefaultQueryObject (ifc, this);
+    } 
+    
+    /**
+     * Intantiate and returns EmbedXAConnection.
+     * @param user 
+     * @param password 
+     * @return XAConnection
+     */
+        protected XAConnection createXAConnection (ResourceAdapter ra, 
+                String user, String password,
+                boolean requestPassword)  throws SQLException {
+            return new EmbedXAConnection40 (this, ra, user, 
+                    password, requestPassword);
+        }
+}

Propchange: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedXADataSource40.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/xaHelper.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/xaHelper.java?rev=393791&r1=393790&r2=393791&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/xaHelper.java (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/xaHelper.java Thu Apr 13 05:49:57 2006
@@ -34,6 +34,7 @@
 import javax.sql.XADataSource;
 import javax.sql.DataSource;
 import javax.sql.ConnectionPoolDataSource;
+import org.apache.derby.iapi.services.info.JVMInfo;
 
 /*
  * The real xa helper class.  Load this class only if we know the javax classes
@@ -503,8 +504,22 @@
 			else if (isNetClient)
 				return (XADataSource) 
 					(Class.forName("org.apache.derby.jdbc.ClientXADataSource").newInstance());
-			else
-				return (XADataSource)(Class.forName("org.apache.derby.jdbc.EmbeddedXADataSource").newInstance());
+			else {
+                            if (JVMInfo.JDK_ID >= JVMInfo.J2SE_16) {
+                                //running under jdk1.6 or higher 
+                                // try instantiating EmbeddedXADataSource40
+                                try {
+                                    return (XADataSource)(Class.forName(
+                                        "org.apache.derby.jdbc." +
+                                        "EmbeddedXADataSource40").newInstance());                                        
+                                }
+                                catch (ClassNotFoundException e) {
+                                    //probably it was not compiled with jdbc4.0
+                                    //support go ahead with EmbeddedXADataSource
+                                }
+                            }
+                            return (XADataSource)(Class.forName("org.apache.derby.jdbc.EmbeddedXADataSource").newInstance());
+                        }
 		}
 		catch(ClassNotFoundException cnfe) {
 			throw new ijException(LocalizedResource.getMessage("IJ_XAClass"));

Modified: db/derby/code/trunk/tools/jar/extraDBMSclasses.properties
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/tools/jar/extraDBMSclasses.properties?rev=393791&r1=393790&r2=393791&view=diff
==============================================================================
--- db/derby/code/trunk/tools/jar/extraDBMSclasses.properties (original)
+++ db/derby/code/trunk/tools/jar/extraDBMSclasses.properties Thu Apr 13 05:49:57 2006
@@ -35,6 +35,8 @@
 #Next line will be uncommented if build with jdk 1.6 support
 #The uncommenting will be handled by {srcroot}/build.xml
 #jdbc4_optional_derby.module.core.csds.jdk16=org.apache.derby.jdbc.EmbeddedDataSource40
+#jdbc4_optional_derby.module.core.csxads.jdk16=org.apache.derby.jdbc.EmbeddedXADataSource40
+#jdbc4_optional_derby.module.core.cscpds.jdk16=org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource40
 
 derby.module.database.consistency.checker=org.apache.derby.iapi.db.ConsistencyChecker
 derby.module.database.optimizer.trace=org.apache.derby.iapi.db.OptimizerTrace