You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by dj...@apache.org on 2005/01/22 16:57:28 UTC

svn commit: r126038 - /incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource.java

Author: djd
Date: Sat Jan 22 07:57:26 2005
New Revision: 126038

URL: http://svn.apache.org/viewcvs?view=rev&rev=126038
Log:
Fix Derby-95 - NullPointerExceptionwith XA Connections if databaseName property
is incorrectly stated as a JDBC URL.
Fix contributed by Shreyas Kaushik <Sh...@Sun.COM>

Modified:
   incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource.java

Modified: incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource.java
Url: http://svn.apache.org/viewcvs/incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource.java?view=diff&rev=126038&p1=incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource.java&r1=126037&p2=incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource.java&r2=126038
==============================================================================
--- incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource.java	(original)
+++ incubator/derby/code/trunk/java/engine/org/apache/derby/jdbc/EmbeddedDataSource.java	Sat Jan 22 07:57:26 2005
@@ -34,6 +34,11 @@
 
 
 import org.apache.derby.iapi.reference.Attribute;
+import org.apache.derby.iapi.reference.MessageId;
+import org.apache.derby.iapi.reference.SQLState;
+import org.apache.derby.iapi.error.ExceptionSeverity;
+import org.apache.derby.iapi.services.i18n.MessageService;
+import org.apache.derby.impl.jdbc.Util;
 
 /** 
 	
@@ -450,6 +455,7 @@
 
 		if (attributesAsPassword && requestPassword && password != null) {
 
+
 			StringBuffer sb = new StringBuffer(url.length() + password.length() + 1);
 
 			sb.append(url);
@@ -459,8 +465,14 @@
 			url = sb.toString();
 
 		}
+		Connection conn =  findDriver().connect(url, info);
+
+	// JDBC driver's getConnection method returns null if
+	// the driver does not handle the request's URL.
+        if (conn == null)
+           throw Util.generateCsSQLException(SQLState.PROPERTY_INVALID_VALUE,Attribute.DBNAME_ATTR,getDatabaseName());
 
-		return findDriver().connect(url, info);
+        return conn;
 	}
    
 	Driver169 findDriver() throws SQLException