db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r438122 - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/ engine/org/apache/derby/loc/ testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/ testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/
Date Tue, 29 Aug 2006 17:25:23 GMT
Author: mikem
Date: Tue Aug 29 10:25:23 2006
New Revision: 438122

URL: http://svn.apache.org/viewvc?rev=438122&view=rev
Log:
DERBY-1130
contributed by Deepa Remesh

Committing patch 'd1130-v2.diff' which ensures that database name set using setConnectionAttributes
does not get used by client data sources. Changes are:

1) Appends the attributes in setConnectionAttributes method to database name only if database
name has been already set on the data source. This will handle both these cases successfully:

a) When database name is not set as a DataSource property - In this case, if we pass in database
name as a connection attribute, it will not get used. databaseName is a required Derby DataSource
property. If it is not set, we cannot get a connection using the DataSource. It will fail
with the following exception:
08001 - Required Derby DataSource property databaseName not set.
So, there is no need to append the connectionAttributes to the database name variable if databaseName
DataSource property is not set. This way, we can avoid using database name in case it is passed
in as a connection attribute.

Without the patch, if database name was not set, the code was using "null" as database name
and creating a database named null if "create=true" is specified or throwing an exception
that it cannot connect to database named null.

b) When database name is set as a DataSource property - In this case, if we pass in database
name as a connection attribute, it will not be used. This is because database name set as
DataSource property will over-ride it. This case is correctly handled (even without the patch).

2) The exception message is changed to indicate we are referring to "Derby DataSource" property:
08001 - Required Derby DataSource property databaseName not set.

3) Adds test to jdbcapi/checkDataSource.java. Adds a new method "testClientDSConnectionAttributes"
which is run only in client framework. Modifies master files. 


Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java
    db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource30.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java?rev=438122&r1=438121&r2=438122&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java Tue Aug 29
10:25:23 2006
@@ -177,12 +177,15 @@
         user_ = user;
 
         // Extract common properties.
-        // Derby-409 fix
-        if (dataSource.getConnectionAttributes() != null) {
-            databaseName_ = dataSource.getDatabaseName() + ";" + dataSource.getConnectionAttributes();
-        } else {
-            databaseName_ = dataSource.getDatabaseName();
-        }
+        // Derby-409 fix - Append connectionAttributes only if it is non-null. 
+        // DERBY-1130 - Append connectionAttributes only if database name is
+        // non-null. This will prevent use of database name set using 
+        // "setConnectionAttributes" method.  
+        databaseName_ = dataSource.getDatabaseName();
+        String connAtrrs = dataSource.getConnectionAttributes();
+        if(databaseName_ != null && connAtrrs != null)
+        	databaseName_ = databaseName_ + ";" + connAtrrs;
+
         retrieveMessageText_ = dataSource.getRetrieveMessageText();
 
         loginTimeout_ = dataSource.getLoginTimeout();

Modified: db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties?rev=438122&r1=438121&r2=438122&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties Tue Aug 29
10:25:23 2006
@@ -1343,7 +1343,7 @@
 
 XXXXX.C.6=Normal database session close.
 
-08001.C.1=Required property {0} not set.
+08001.C.1=Required Derby DataSource property {0} not set.
 08001.C.2={0} : Error connecting to server {1} on port {2} with message {3}.
 08001.C.3=SocketException: ''{0}''
 08001.C.4=Unable to open stream on socket: ''{0}''.

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource.out?rev=438122&r1=438121&r2=438122&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource.out
Tue Aug 29 10:25:23 2006
@@ -555,4 +555,95 @@
 acxs 3
 testing jira 95 for DataSource; ok - expected exception: XCY00
 testing jira 95 for XADataSource; ok - expected exception: XCY00
+DataSource - EMPTY
+  getConnection() - 08001:Required Derby DataSource property databaseName not set.
+  getConnection(null, null) - 08001:Required Derby DataSource property databaseName not set.
+  getConnection(fred, null) - 08001:Required Derby DataSource property databaseName not set.
+  getConnection(fred, wilma) - 08001:Required Derby DataSource property databaseName not
set.
+  getConnection(null, wilma) - 08001:Required Derby DataSource property databaseName not
set.
+  getConnection(null, databaseName=wombat) - 08001:Required Derby DataSource property databaseName
not set.
+  getConnection(fred, databaseName=wombat) - 08001:Required Derby DataSource property databaseName
not set.
+  getConnection(fred, databaseName=wombat;password=wilma) - 08001:Required Derby DataSource
property databaseName not set.
+  getConnection(fred, databaseName=wombat;password=betty) - 08001:Required Derby DataSource
property databaseName not set.
+DataSource - connectionAttributes=databaseName=wombat
+  getConnection() - 08001:Required Derby DataSource property databaseName not set.
+  getConnection(null, null) - 08001:Required Derby DataSource property databaseName not set.
+  getConnection(fred, null) - 08001:Required Derby DataSource property databaseName not set.
+  getConnection(fred, wilma) - 08001:Required Derby DataSource property databaseName not
set.
+  getConnection(null, wilma) - 08001:Required Derby DataSource property databaseName not
set.
+  getConnection(null, databaseName=wombat) - 08001:Required Derby DataSource property databaseName
not set.
+  getConnection(fred, databaseName=wombat) - 08001:Required Derby DataSource property databaseName
not set.
+  getConnection(fred, databaseName=wombat;password=wilma) - 08001:Required Derby DataSource
property databaseName not set.
+  getConnection(fred, databaseName=wombat;password=betty) - 08001:Required Derby DataSource
property databaseName not set.
+DataSource - databaseName=wombat and connectionAttributes=databaseName=kangaroo
+  getConnection() - OK
+  getConnection(null, null) - 08001:User id can not be null.
+  getConnection(fred, null) - OK
+  getConnection(fred, wilma) - OK
+  getConnection(null, wilma) - 08001:User id can not be null.
+  getConnection(null, databaseName=wombat) - 08001:User id can not be null.
+  getConnection(fred, databaseName=wombat) - OK
+  getConnection(fred, databaseName=wombat;password=wilma) - OK
+  getConnection(fred, databaseName=wombat;password=betty) - OK
+ConnectionPoolDataSource - EMPTY
+  getPooledConnection() - 08001:Required Derby DataSource property databaseName not set.
+  getPooledConnection(null, null) - 08001:Required Derby DataSource property databaseName
not set.
+  getPooledConnection(fred, null) - 08001:Required Derby DataSource property databaseName
not set.
+  getPooledConnection(fred, wilma) - 08001:Required Derby DataSource property databaseName
not set.
+  getPooledConnection(null, wilma) - 08001:Required Derby DataSource property databaseName
not set.
+  getPooledConnection(null, databaseName=wombat) - 08001:Required Derby DataSource property
databaseName not set.
+  getPooledConnection(fred, databaseName=wombat) - 08001:Required Derby DataSource property
databaseName not set.
+  getPooledConnection(fred, databaseName=wombat;password=wilma) - 08001:Required Derby DataSource
property databaseName not set.
+  getPooledConnection(fred, databaseName=wombat;password=betty) - 08001:Required Derby DataSource
property databaseName not set.
+ConnectionPoolDataSource - connectionAttributes=databaseName=wombat
+  getPooledConnection() - 08001:Required Derby DataSource property databaseName not set.
+  getPooledConnection(null, null) - 08001:Required Derby DataSource property databaseName
not set.
+  getPooledConnection(fred, null) - 08001:Required Derby DataSource property databaseName
not set.
+  getPooledConnection(fred, wilma) - 08001:Required Derby DataSource property databaseName
not set.
+  getPooledConnection(null, wilma) - 08001:Required Derby DataSource property databaseName
not set.
+  getPooledConnection(null, databaseName=wombat) - 08001:Required Derby DataSource property
databaseName not set.
+  getPooledConnection(fred, databaseName=wombat) - 08001:Required Derby DataSource property
databaseName not set.
+  getPooledConnection(fred, databaseName=wombat;password=wilma) - 08001:Required Derby DataSource
property databaseName not set.
+  getPooledConnection(fred, databaseName=wombat;password=betty) - 08001:Required Derby DataSource
property databaseName not set.
+ConnectionPoolDataSource - databaseName=wombat and connectionAttributes=databaseName=kangaroo
+  getPooledConnection() - OK
+  getPooledConnection(null, null) - 08001:User id can not be null.
+  getPooledConnection(fred, null) - OK
+  getPooledConnection(fred, wilma) - OK
+  getPooledConnection(null, wilma) - 08001:User id can not be null.
+  getPooledConnection(null, databaseName=wombat) - 08001:User id can not be null.
+  getPooledConnection(fred, databaseName=wombat) - OK
+  getPooledConnection(fred, databaseName=wombat;password=wilma) - OK
+  getPooledConnection(fred, databaseName=wombat;password=betty) - OK
+XADataSource - EMPTY
+  getXAConnection() - 08001:Required Derby DataSource property databaseName not set.
+  getXAConnection(null, null) - 08001:Required Derby DataSource property databaseName not
set.
+  getXAConnection(fred, null) - 08001:Required Derby DataSource property databaseName not
set.
+  getXAConnection(fred, wilma) - 08001:Required Derby DataSource property databaseName not
set.
+  getXAConnection(null, wilma) - 08001:Required Derby DataSource property databaseName not
set.
+  getXAConnection(null, databaseName=wombat) - 08001:Required Derby DataSource property databaseName
not set.
+  getXAConnection(fred, databaseName=wombat) - 08001:Required Derby DataSource property databaseName
not set.
+  getXAConnection(fred, databaseName=wombat;password=wilma) - 08001:Required Derby DataSource
property databaseName not set.
+  getXAConnection(fred, databaseName=wombat;password=betty) - 08001:Required Derby DataSource
property databaseName not set.
+XADataSource - connectionAttributes=databaseName=wombat
+  getXAConnection() - 08001:Required Derby DataSource property databaseName not set.
+  getXAConnection(null, null) - 08001:Required Derby DataSource property databaseName not
set.
+  getXAConnection(fred, null) - 08001:Required Derby DataSource property databaseName not
set.
+  getXAConnection(fred, wilma) - 08001:Required Derby DataSource property databaseName not
set.
+  getXAConnection(null, wilma) - 08001:Required Derby DataSource property databaseName not
set.
+  getXAConnection(null, databaseName=wombat) - 08001:Required Derby DataSource property databaseName
not set.
+  getXAConnection(fred, databaseName=wombat) - 08001:Required Derby DataSource property databaseName
not set.
+  getXAConnection(fred, databaseName=wombat;password=wilma) - 08001:Required Derby DataSource
property databaseName not set.
+  getXAConnection(fred, databaseName=wombat;password=betty) - 08001:Required Derby DataSource
property databaseName not set.
+XADataSource - databaseName=wombat and connectionAttributes=databaseName=kangaroo
+  getXAConnection() - OK
+  getXAConnection(null, null) - 08001:User id can not be null.
+  getXAConnection(fred, null) - OK
+  getXAConnection(fred, wilma) - OK
+  getXAConnection(null, wilma) - 08001:User id can not be null.
+  getXAConnection(null, databaseName=wombat) - 08001:User id can not be null.
+  getXAConnection(fred, databaseName=wombat) - OK
+  getXAConnection(fred, databaseName=wombat;password=wilma) - OK
+  getXAConnection(fred, databaseName=wombat;password=betty) - OK
+Checked class declared as: javax.sql.DataSource
 Completed checkDataSource

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource30.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource30.out?rev=438122&r1=438121&r2=438122&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource30.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource30.out
Tue Aug 29 10:25:23 2006
@@ -672,6 +672,96 @@
 acxs 3
 testing jira 95 for DataSource; ok - expected exception: XCY00
 testing jira 95 for XADataSource; ok - expected exception: XCY00
+DataSource - EMPTY
+  getConnection() - 08001:Required Derby DataSource property databaseName not set.
+  getConnection(null, null) - 08001:Required Derby DataSource property databaseName not set.
+  getConnection(fred, null) - 08001:Required Derby DataSource property databaseName not set.
+  getConnection(fred, wilma) - 08001:Required Derby DataSource property databaseName not
set.
+  getConnection(null, wilma) - 08001:Required Derby DataSource property databaseName not
set.
+  getConnection(null, databaseName=wombat) - 08001:Required Derby DataSource property databaseName
not set.
+  getConnection(fred, databaseName=wombat) - 08001:Required Derby DataSource property databaseName
not set.
+  getConnection(fred, databaseName=wombat;password=wilma) - 08001:Required Derby DataSource
property databaseName not set.
+  getConnection(fred, databaseName=wombat;password=betty) - 08001:Required Derby DataSource
property databaseName not set.
+DataSource - connectionAttributes=databaseName=wombat
+  getConnection() - 08001:Required Derby DataSource property databaseName not set.
+  getConnection(null, null) - 08001:Required Derby DataSource property databaseName not set.
+  getConnection(fred, null) - 08001:Required Derby DataSource property databaseName not set.
+  getConnection(fred, wilma) - 08001:Required Derby DataSource property databaseName not
set.
+  getConnection(null, wilma) - 08001:Required Derby DataSource property databaseName not
set.
+  getConnection(null, databaseName=wombat) - 08001:Required Derby DataSource property databaseName
not set.
+  getConnection(fred, databaseName=wombat) - 08001:Required Derby DataSource property databaseName
not set.
+  getConnection(fred, databaseName=wombat;password=wilma) - 08001:Required Derby DataSource
property databaseName not set.
+  getConnection(fred, databaseName=wombat;password=betty) - 08001:Required Derby DataSource
property databaseName not set.
+DataSource - databaseName=wombat and connectionAttributes=databaseName=kangaroo
+  getConnection() - OK
+  getConnection(null, null) - 08001:User id can not be null.
+  getConnection(fred, null) - OK
+  getConnection(fred, wilma) - OK
+  getConnection(null, wilma) - 08001:User id can not be null.
+  getConnection(null, databaseName=wombat) - 08001:User id can not be null.
+  getConnection(fred, databaseName=wombat) - OK
+  getConnection(fred, databaseName=wombat;password=wilma) - OK
+  getConnection(fred, databaseName=wombat;password=betty) - OK
+ConnectionPoolDataSource - EMPTY
+  getPooledConnection() - 08001:Required Derby DataSource property databaseName not set.
+  getPooledConnection(null, null) - 08001:Required Derby DataSource property databaseName
not set.
+  getPooledConnection(fred, null) - 08001:Required Derby DataSource property databaseName
not set.
+  getPooledConnection(fred, wilma) - 08001:Required Derby DataSource property databaseName
not set.
+  getPooledConnection(null, wilma) - 08001:Required Derby DataSource property databaseName
not set.
+  getPooledConnection(null, databaseName=wombat) - 08001:Required Derby DataSource property
databaseName not set.
+  getPooledConnection(fred, databaseName=wombat) - 08001:Required Derby DataSource property
databaseName not set.
+  getPooledConnection(fred, databaseName=wombat;password=wilma) - 08001:Required Derby DataSource
property databaseName not set.
+  getPooledConnection(fred, databaseName=wombat;password=betty) - 08001:Required Derby DataSource
property databaseName not set.
+ConnectionPoolDataSource - connectionAttributes=databaseName=wombat
+  getPooledConnection() - 08001:Required Derby DataSource property databaseName not set.
+  getPooledConnection(null, null) - 08001:Required Derby DataSource property databaseName
not set.
+  getPooledConnection(fred, null) - 08001:Required Derby DataSource property databaseName
not set.
+  getPooledConnection(fred, wilma) - 08001:Required Derby DataSource property databaseName
not set.
+  getPooledConnection(null, wilma) - 08001:Required Derby DataSource property databaseName
not set.
+  getPooledConnection(null, databaseName=wombat) - 08001:Required Derby DataSource property
databaseName not set.
+  getPooledConnection(fred, databaseName=wombat) - 08001:Required Derby DataSource property
databaseName not set.
+  getPooledConnection(fred, databaseName=wombat;password=wilma) - 08001:Required Derby DataSource
property databaseName not set.
+  getPooledConnection(fred, databaseName=wombat;password=betty) - 08001:Required Derby DataSource
property databaseName not set.
+ConnectionPoolDataSource - databaseName=wombat and connectionAttributes=databaseName=kangaroo
+  getPooledConnection() - OK
+  getPooledConnection(null, null) - 08001:User id can not be null.
+  getPooledConnection(fred, null) - OK
+  getPooledConnection(fred, wilma) - OK
+  getPooledConnection(null, wilma) - 08001:User id can not be null.
+  getPooledConnection(null, databaseName=wombat) - 08001:User id can not be null.
+  getPooledConnection(fred, databaseName=wombat) - OK
+  getPooledConnection(fred, databaseName=wombat;password=wilma) - OK
+  getPooledConnection(fred, databaseName=wombat;password=betty) - OK
+XADataSource - EMPTY
+  getXAConnection() - 08001:Required Derby DataSource property databaseName not set.
+  getXAConnection(null, null) - 08001:Required Derby DataSource property databaseName not
set.
+  getXAConnection(fred, null) - 08001:Required Derby DataSource property databaseName not
set.
+  getXAConnection(fred, wilma) - 08001:Required Derby DataSource property databaseName not
set.
+  getXAConnection(null, wilma) - 08001:Required Derby DataSource property databaseName not
set.
+  getXAConnection(null, databaseName=wombat) - 08001:Required Derby DataSource property databaseName
not set.
+  getXAConnection(fred, databaseName=wombat) - 08001:Required Derby DataSource property databaseName
not set.
+  getXAConnection(fred, databaseName=wombat;password=wilma) - 08001:Required Derby DataSource
property databaseName not set.
+  getXAConnection(fred, databaseName=wombat;password=betty) - 08001:Required Derby DataSource
property databaseName not set.
+XADataSource - connectionAttributes=databaseName=wombat
+  getXAConnection() - 08001:Required Derby DataSource property databaseName not set.
+  getXAConnection(null, null) - 08001:Required Derby DataSource property databaseName not
set.
+  getXAConnection(fred, null) - 08001:Required Derby DataSource property databaseName not
set.
+  getXAConnection(fred, wilma) - 08001:Required Derby DataSource property databaseName not
set.
+  getXAConnection(null, wilma) - 08001:Required Derby DataSource property databaseName not
set.
+  getXAConnection(null, databaseName=wombat) - 08001:Required Derby DataSource property databaseName
not set.
+  getXAConnection(fred, databaseName=wombat) - 08001:Required Derby DataSource property databaseName
not set.
+  getXAConnection(fred, databaseName=wombat;password=wilma) - 08001:Required Derby DataSource
property databaseName not set.
+  getXAConnection(fred, databaseName=wombat;password=betty) - 08001:Required Derby DataSource
property databaseName not set.
+XADataSource - databaseName=wombat and connectionAttributes=databaseName=kangaroo
+  getXAConnection() - OK
+  getXAConnection(null, null) - 08001:User id can not be null.
+  getXAConnection(fred, null) - OK
+  getXAConnection(fred, wilma) - OK
+  getXAConnection(null, wilma) - 08001:User id can not be null.
+  getXAConnection(null, databaseName=wombat) - 08001:User id can not be null.
+  getXAConnection(fred, databaseName=wombat) - OK
+  getXAConnection(fred, databaseName=wombat;password=wilma) - OK
+  getXAConnection(fred, databaseName=wombat;password=betty) - OK
 START XA HOLDABILITY TEST
 By default, autocommit is true for a connection
 Default holdability for a connection is HOLD_CURSORS_OVER_COMMIT
@@ -740,4 +830,5 @@
 Get a new connection with XAConnection.getConnection()
 Isolation level should be reset to READ_COMMITTED
 PASS: Expected lock timeout for READ_COMMITTED
+Checked class declared as: javax.sql.DataSource
 Completed checkDataSource30

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java?rev=438122&r1=438121&r2=438122&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
Tue Aug 29 10:25:23 2006
@@ -47,6 +47,10 @@
 import org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource;
 import org.apache.derby.jdbc.EmbeddedDataSource;
 import org.apache.derby.jdbc.EmbeddedXADataSource;
+import org.apache.derby.jdbc.ClientConnectionPoolDataSource;
+import org.apache.derby.jdbc.ClientDataSource;
+import org.apache.derby.jdbc.ClientXADataSource;
+
 import org.apache.derby.tools.JDBCDisplayUtil;
 import org.apache.derby.tools.ij;
 import org.apache.derbyTesting.functionTests.util.SecurityCheck;
@@ -686,11 +690,13 @@
 		} catch (Exception e) {
 				System.out.println("; wrong, unexpected exception: " + e.toString());
 		}
-		// skip testDSRequestAuthentication for  client because of these 
-		// two issues:
-		// DERBY-1130 : Client should not allow databaseName to be set with
-		// setConnectionAttributes
+		
+		if (TestUtil.isDerbyNetClientFramework())
+			testClientDSConnectionAttributes();
+		
+		// skip testDSRequestAuthentication for  client because of this issue: 
 		// DERBY-1131 : Deprecate  Derby DataSource property attributesAsPassword
+		// First part of this test is covered by testClientDSConnectionAttributes()
 		if (TestUtil.isDerbyNetClientFramework())
 			return;
 		testDSRequestAuthentication();
@@ -1383,6 +1389,69 @@
 		xads.setDatabaseName(null);
 	}
 
+	/**
+	 * Check that database name set using setConnectionAttributes is not used
+	 * by ClientDataSource. This method tests DERBY-1130.
+	 * 
+	 * @throws SQLException
+	 */
+	private static void testClientDSConnectionAttributes() throws SQLException {
+
+		ClientDataSource ds = new ClientDataSource();
+
+		System.out.println("DataSource - EMPTY");
+		dsConnectionRequests(ds);
+
+		System.out.println("DataSource - connectionAttributes=databaseName=wombat");
+		ds.setConnectionAttributes("databaseName=wombat");
+		dsConnectionRequests(ds);
+		ds.setConnectionAttributes(null);
+		
+		// Test that database name specified in connection attributes is not used
+		System.out.println("DataSource - databaseName=wombat and connectionAttributes=databaseName=kangaroo");
+		ds.setConnectionAttributes("databaseName=kangaroo");
+		ds.setDatabaseName("wombat");
+		dsConnectionRequests(ds);
+		ds.setConnectionAttributes(null);
+		ds.setDatabaseName(null);
+		
+		// now with ConnectionPoolDataSource
+		ClientConnectionPoolDataSource cpds = new ClientConnectionPoolDataSource();
+		System.out.println("ConnectionPoolDataSource - EMPTY");
+		dsConnectionRequests((ConnectionPoolDataSource)cpds);
+
+		System.out.println("ConnectionPoolDataSource - connectionAttributes=databaseName=wombat");
+		cpds.setConnectionAttributes("databaseName=wombat");
+		dsConnectionRequests((ConnectionPoolDataSource)cpds);
+		cpds.setConnectionAttributes(null);
+		
+		// Test that database name specified in connection attributes is not used
+		System.out.println("ConnectionPoolDataSource - databaseName=wombat and connectionAttributes=databaseName=kangaroo");
+		cpds.setConnectionAttributes("databaseName=kangaroo");
+		cpds.setDatabaseName("wombat");
+		dsConnectionRequests((ConnectionPoolDataSource)cpds);
+		cpds.setConnectionAttributes(null);
+		cpds.setDatabaseName(null);
+		
+		// now with XADataSource
+		ClientXADataSource xads = new ClientXADataSource();
+		System.out.println("XADataSource - EMPTY");
+		dsConnectionRequests((XADataSource) xads);
+
+		System.out.println("XADataSource - connectionAttributes=databaseName=wombat");
+		xads.setConnectionAttributes("databaseName=wombat");
+		dsConnectionRequests((XADataSource) xads);
+		xads.setConnectionAttributes(null);
+		
+		// Test that database name specified in connection attributes is not used
+		System.out.println("XADataSource - databaseName=wombat and connectionAttributes=databaseName=kangaroo");
+		xads.setConnectionAttributes("databaseName=kangaroo");
+		xads.setDatabaseName("wombat");
+		dsConnectionRequests((XADataSource) xads);
+		xads.setConnectionAttributes(null);
+		xads.setDatabaseName(null);
+	}
+	
 	private static void dsConnectionRequests(DataSource ds) {
 		
 		SecurityCheck.inspect(ds, "javax.sql.DataSource");



Mime
View raw message