Issue Details (XML | Word | Printable)

Key: DERBY-1130
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Deepa Remesh
Reporter: Kathey Marsden
Votes: 1
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Derby

Client should not allow databaseName to be set with setConnectionAttributes

Created: 21/Mar/06 12:27 AM   Updated: 30/Jun/09 04:12 PM
Return to search
Component/s: Network Client
Affects Version/s: 10.1.1.0, 10.1.2.1, 10.1.3.1, 10.2.1.6
Fix Version/s: 10.2.2.1

Time Tracking:
Not Specified

File Attachments:
  Size
File Licensed for inclusion in ASF works d1130-client-v1.diff 2006-08-07 07:26 PM Deepa Remesh 15 kB
File Licensed for inclusion in ASF works d1130-client-v1.status 2006-08-07 07:26 PM Deepa Remesh 0.6 kB
File Licensed for inclusion in ASF works d1130-test-dataSourceReference.diff 2006-08-11 04:36 PM Deepa Remesh 11 kB
File Licensed for inclusion in ASF works d1130-test-dataSourceReference.status 2006-08-11 04:36 PM Deepa Remesh 0.3 kB
File Licensed for inclusion in ASF works d1130-v2.diff 2006-08-12 08:53 PM Deepa Remesh 23 kB
File Licensed for inclusion in ASF works d1130-v2.status 2006-08-12 08:53 PM Deepa Remesh 0.5 kB
File Licensed for inclusion in ASF works derby-1130-v1.diff 2006-07-17 09:58 PM Deepa Remesh 20 kB
File Licensed for inclusion in ASF works derby-1130-v1.status 2006-07-17 09:58 PM Deepa Remesh 0.4 kB

Issue & fix info: Release Note Needed
Resolution Date: 15/May/07 07:50 PM


 Description  « Hide
Per this thread, setConnectionAttributes should not set databaseName.

http://www.nabble.com/double-check-on-checkDataSource-t1187602.html#a3128621

Currently this is allowed for client but should be disabled. I think it is OK to change because we have documented that client will be changed to match embedded for implementation defined behaviour. Hopefully its use is rare as most folks would use the standard setDatabaseName. Still there should be a release not when the change is made and it would be better to change it sooner than later:

Below is the repro.

Here is the output with Client
D>java DatabaseNameWithSetConnAttr
ds.setConnectionAttributes(databaseName=wombat;create=true)
ds.getDatabaseName() = null (should be null)
FAIL: Should not have been able to set databaseName with connection attributes

Also look for tests disabled with this bug number in the test checkDataSource30.java



import java.sql.*;
import java.lang.reflect.Method;


public class DatabaseNameWithSetConnAttr{

public static void main(String[] args) {
try {

String attributes = "databaseName=wombat;create=true";
org.apache.derby.jdbc.ClientDataSource ds = new
org.apache.derby.jdbc.ClientDataSource();

//org.apache.derby.jdbc.EmbeddedDataSource ds = new
//org.apache.derby.jdbc.EmbeddedDataSource();
System.out.println("ds.setConnectionAttributes(" + attributes + ")");
ds.setConnectionAttributes(attributes);
System.out.println("ds.getDatabaseName() = " +
ds.getDatabaseName() + " (should be null)" );

Connection conn = ds.getConnection();

} catch (SQLException e) {
String sqlState = e.getSQLState();
if (sqlState != null && sqlState.equals("XJ041"))
{
System.out.println("PASS: An exception was thrown trying to get a connetion from a datasource after setting databaseName with setConnectionAttributes");
System.out.println("EXPECTED EXCEPTION: " + e.getSQLState()
+ " - " + e.getMessage());
return;
}
while (e != null)
{
System.out.println("FAIL - UNEXPECTED EXCEPTION: " + e.getSQLState());
e.printStackTrace();
e = e.getNextException();
}
return;
}
System.out.println("FAIL: Should not have been able to set databaseName with connection attributes");

}

}


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #430641 Fri Aug 11 03:34:22 UTC 2006 kmarsden DERBY-1130 Client should not allow databaseName to be set with setConnectionAttributes

Attaching a patch 'd1130-client-v1.diff' which disallows databaseName attribute to be set using setConnectionAttributes method in client data sources. Tests added to jdbcapi/checkDataSource.java.


Contributed by Deepa Remesh
Files Changed
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
MODIFY /db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource30.out
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource.out
MODIFY /db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
MODIFY /db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties
MODIFY /db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDataSource.java

Repository Revision Date User Message
ASF #430891 Fri Aug 11 20:50:29 UTC 2006 kmarsden Backout change for

DERBY-1130 Client should not allow databaseName to be set with setConnectionAttributes

To address concerns with the patch
Files Changed
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
MODIFY /db/derby/code/trunk/java/shared/org/apache/derby/shared/common/reference/SQLState.java
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource30.out
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource.out
MODIFY /db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
MODIFY /db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties
MODIFY /db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDataSource.java

Repository Revision Date User Message
ASF #432651 Fri Aug 18 17:20:30 UTC 2006 rhillegas DERBY-1725: Merge trunk into 10.2 branch from 430858 through 430945. Merges in patches to the following JIRAs: DERBY-1130 DERBY-1556 DERBY-1593.
Files Changed
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ScrollResultSetTest.java
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ProcedureTest.java
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ConcurrencyTest.java
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource30.out
MODIFY /db/derby/code/branches/10.2/java/engine/org/apache/derby/loc/messages_en.properties
MODIFY /db/derby/code/branches/10.2/java/client/org/apache/derby/jdbc/ClientDataSource.java
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangScripts.java
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/util/BaseTestCase.java
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource.out
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/util/SecurityManagerSetup.java
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/util/ScriptTestCase.java
DEL /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ConcurrencyTest_app.properties
MODIFY /db/derby/code/branches/10.2/tools/release/build.xml
MODIFY /db/derby/code/branches/10.2/java/shared/org/apache/derby/shared/common/reference/SQLState.java
ADD /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/util/CleanDatabaseTestSetup.java (from /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/util/CleanDatabaseTestSetup.java)
MODIFY /db/derby/code/branches/10.2/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
ADD /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java (from /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite.java)
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/build.xml
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/util/TestConfiguration.java
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java

Repository Revision Date User Message
ASF #432715 Fri Aug 18 20:24:00 UTC 2006 rhillegas DERBY-1725: Dummy commit to record the following linkages just in case I failed to correctly update the commit comments for the previous commits on this issue. The preceding commits merged the following patches from the trunk to the 10.2 branch: Merge 1 (432641): DERBY-1556. Merge 2 (432651): DERBY-1130 DERBY-1556 DERBY-1593. Merge 3 (432658): DERBY-415 DERBY-1652 DERBY-1694 DERBY-1691 DERBY-1688 DERBY-1574 DERBY-766 DERBY-1664 DERBY-634. Merge 4 (432679): DERBY-244 DERBY-1710 DERBY-1712 DERBY-1555 DERBY-1701 DERBY-1691 DERBY-1681 DERBY-1032 DERBY-1692.
Files Changed
MODIFY /db/derby/code/branches/10.2/BUILDING.txt

Repository Revision Date User Message
ASF #438122 Tue Aug 29 17:25:23 UTC 2006 mikem 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.
Files Changed
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java
MODIFY /db/derby/code/trunk/java/client/org/apache/derby/client/am/Connection.java
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource30.out
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource.out
MODIFY /db/derby/code/trunk/java/engine/org/apache/derby/loc/messages_en.properties

Repository Revision Date User Message
ASF #439370 Fri Sep 01 16:28:19 UTC 2006 rhillegas DERBY-1725: Port the following patches from trunk to the 10.2 branch: No JIRA (438578, 438489, 438289, 438273, 438211), DERBY-1559 (438478), DERBY-1555 (438299), DERBY-1130 (438122).
Files Changed
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/schema1.out
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/junit/ChangeConfigurationSetup.java
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/schema5.out
ADD /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/junit/ChangeUserSetup.java (from /db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/ChangeUserSetup.java)
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/nist/schema1.sql
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource30.out
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/_Suite_app.properties
MODIFY /db/derby/code/branches/10.2/java/engine/org/apache/derby/loc/messages_en.properties
ADD /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/nist/NistScripts.java (from /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/nist/NistScripts.java)
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/nist/schema5.sql
ADD /db/derby/code/branches/10.2/java/drda/org/apache/derby/impl/drda/EXTDTAReaderInputStream.java (from /db/derby/code/trunk/java/drda/org/apache/derby/impl/drda/EXTDTAReaderInputStream.java)
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDataSource.out
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/nist/build.xml
MODIFY /db/derby/code/branches/10.2/java/client/org/apache/derby/client/am/Connection.java
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/basetab.out
MODIFY /db/derby/code/branches/10.2/java/drda/org/apache/derby/impl/drda/DDMReader.java
MODIFY /db/derby/code/branches/10.2/tools/release/build.xml
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/nist/readme
MODIFY /db/derby/code/branches/10.2/java/drda/org/apache/derby/impl/drda/DRDAConnThread.java
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/nist/basetab.sql
MODIFY /db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/catalog/TabInfoImpl.java
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDataSource.java