Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 39367 invoked from network); 12 Jul 2006 14:27:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 12 Jul 2006 14:27:31 -0000 Received: (qmail 93099 invoked by uid 500); 12 Jul 2006 14:27:30 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 93059 invoked by uid 500); 12 Jul 2006 14:27:30 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 93049 invoked by uid 99); 12 Jul 2006 14:27:30 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Jul 2006 07:27:30 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [209.237.227.198] (HELO brutus.apache.org) (209.237.227.198) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Jul 2006 07:27:29 -0700 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 27B0D4104ED for ; Wed, 12 Jul 2006 14:25:31 +0000 (GMT) Message-ID: <10684425.1152714331160.JavaMail.jira@brutus> Date: Wed, 12 Jul 2006 14:25:31 +0000 (GMT+00:00) From: "Deepa Remesh (JIRA)" To: derby-dev@db.apache.org Subject: [jira] Commented: (DERBY-1130) Client should not allow databaseName to be set with setConnectionAttributes In-Reply-To: <1697541913.1142872146208.JavaMail.jira@ajax> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ http://issues.apache.org/jira/browse/DERBY-1130?page=comments#action_12420626 ] Deepa Remesh commented on DERBY-1130: ------------------------------------- For Kathey's question: What is the exception for embedded if create=true is not specified? e.g. ds.setConnectionAttributes("databaseName=wombat") Exception for embedded is: XJ004 - Database '' not found. I think we do not have the same SQL state in the client for the above exception. The corresponding SQLState is "08004 - The connection was refused because the database {0} was not found." As the SQLStates do not match, I was thinking it would be okay to catch the exception at client itself and throw "08001 - Required property databaseName not set. " if database name is not set using setDatabaseName on the client data source. In case the database name is set using setDatabaseName and we try to over-ride it using "databaseName" property in setConnectionAttributes, the over-riding will fail. Only the database name set using setDatabaseName will be used. This was the behaviour in the patch I was working on. However, if the above exception is confusing, I'll try to set a dummy database name on the client and send it to server to get back "08004 - The connection was refused because the database {0} was not found.". Please share your thoughts on this. > Client should not allow databaseName to be set with setConnectionAttributes > --------------------------------------------------------------------------- > > Key: DERBY-1130 > URL: http://issues.apache.org/jira/browse/DERBY-1130 > Project: Derby > Type: Bug > Components: Network Client > 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 > Assignee: Deepa Remesh > > 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