[ 
http://issues.apache.org/jira/browse/DERBY-1130?page=comments#action_12422246 ] 
            
Daniel John Debrunner commented on DERBY-1130:
----------------------------------------------

David wrote:
  - I think it's confusing that when someone does try to use 
connectionAttributes to set the database name, the error they get is "Required 
property databaseName is not set". They'll scratch their heads and say "doggone 
it, right here in my code I'm setting it using connectionAttributes! What the 
heck am I doing wrong? Doth mine eyes deceive me?" 
 
    djd> Probably not always clear, but 'connectionAttributes'  sets JDBC 
attributes for the connection and here we have 'databaseName' being an 
*attribute* in connectionAttributes and a Java bean *property* for the 
DataSource object. Thus the message is technically correct, the *property* has 
not been set.

David again:

 - I actually think the exception on the embedded side similarly is confusing, 
saying the database is not found. I would like something that explicitly says 
something like "you can not set the database name using connection attributes. 
Please use setDatabaseName" 

   djd> I think such a mesage needs to be more generic in how the Java bean 
property databaseName is set rather than stating use setDatabaseName. Most 
users will not be calling methods against Derby's DataSourrce implementations, 
but instead setting fields in a web GUI or modifying configuration files.

Maybe the solution is to be more specific on the term property, replace with 
'Derby DataSource property'?
 

> Client should not allow databaseName to be set with setConnectionAttributes
> ---------------------------------------------------------------------------
>
>                 Key: DERBY-1130
>                 URL: http://issues.apache.org/jira/browse/DERBY-1130
>             Project: Derby
>          Issue Type: Bug
>          Components: Network Client
>    Affects Versions: 10.1.1.0, 10.1.1.1, 10.1.1.2, 10.1.2.0, 10.1.2.1, 
> 10.1.2.2, 10.1.2.3, 10.2.0.0, 10.1.3.0, 10.1.2.4
>            Reporter: Kathey Marsden
>         Assigned To: Deepa Remesh
>         Attachments: derby-1130-v1.diff, derby-1130-v1.status
>
>
> 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");
>       }
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to