Daniel John Debrunner wrote:
I see your point. My initial test case was overly simplistic - never actually did anything with the connection.-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
myrna wrote:
It does no longer throw an NPE, and it passes all tests....
Could we leave EmbeddedDataSource alone & only change
EmbeddedXADataSource? Only with the xa datasource did we get a NPE...
Although strictly speaking, it should behave the same, so, with
EmbeddedDataSource too, we should accept the databasename only, it's
been able to resolve the url fine. I'd be apprehensive about any
possible cloudscape customers that have mistakenly used this
functionality...
I agree with Shreyas that his patch is logically correct but I want to ensure that your concerns are addressed. Can you be explicit about what you believe the patch breaks for existing users of Derby. I tried this and it results in a NullPointerException if the return from getConnection() is referenced, e.g. in the conn.close() here. (this is before the patch is applied)
org.apache.derby.jdbc.EmbeddedDataSource ds = new org.apache.derby.jdbc.EmbeddedDataSource();
ds.setDatabaseName("jdbc:derby:fred");
Connection conn = ds.getConnection();
// NPE here because conn is null conn.close();
The only issue I have with the patch is that the error thrown is misleading, "Database Not Available" implies to the user or application developer that they need to do something to make the database available. A database not found exception with the name obtained from DataSource.getDatabaseName() might make more sense. Or maybe even better, invalid property setting error, since databaseName is a Java Bean property of the datasource. E.g. SQLState.PROPERTY_INVALID_VALUE, resulting in an error like
Invalid value for property 'databaseName'='jdbc:derby:fred'.
Thanks, Dan. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFB7rJnIv0S4qsbfuQRApTGAKDj+MxB4kOY/GNFCMs/9R5Js3zK2wCgqYSm DrAWFRgPOfwMHin0vUwGi70= =zL6e -----END PGP SIGNATURE-----
Myrna
