Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=46298
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 28 Dec 2008 23:46:49 +0000 (23:46 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 28 Dec 2008 23:46:49 +0000 (23:46 +0000)
Throw an exception if the driver doesn't support the supplied URL
Based on a patch by Owen Jacobson

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@729809 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/realm/JDBCRealm.java
java/org/apache/catalina/realm/LocalStrings.properties

index 949d0e0..7cd17d0 100644 (file)
@@ -700,6 +700,10 @@ public class JDBCRealm
         if (connectionPassword != null)
             props.put("password", connectionPassword);
         dbConnection = driver.connect(connectionURL, props);
+        if (dbConnection == null) {
+            throw new SQLException(sm.getString(
+                    "jdbcRealm.open.invalidurl",driverName, connectionURL));
+        }
         dbConnection.setAutoCommit(false);
         return (dbConnection);
 
index 03f5ecb..88b42e4 100644 (file)
@@ -53,6 +53,7 @@ jdbcRealm.exception=Exception performing authentication
 jdbcRealm.getPassword.exception=Exception retrieving password for "{0}"
 jdbcRealm.getRoles.exception=Exception retrieving roles for "{0}"
 jdbcRealm.open=Exception opening database connection
+jdbcRealm.open.invalidurl=Driver "{0}" does not support the url "{1}"
 jndiRealm.authenticateFailure=Username {0} NOT successfully authenticated
 jndiRealm.authenticateSuccess=Username {0} successfully authenticated
 jndiRealm.close=Exception closing directory server connection