The problem (in DriverManagerConnectionFactory.java):

If you supply a username but not a password, or a password but not a
username, dbcp ignores these values, and simply uses the URL to connect
to your database (even when defaults exist for the null values). This
means if I create a DriverManagerConnectionFactory with url, user and
pass of mydburl, myusername, null, it will try connect to mydburl using
default username and default password rather than myusername and default
password.

The solution:
Allow the default username and password values to be used when one is
present but the other is not, as provided by the patch. Now I realise
default usernames/passwords are not ideal, but at the same time there's
no need to prevent this functionality from working (imho).

Regards,

Max
-- 
Maxwell Grender-Jones   <[EMAIL PROTECTED]> 
http://www.mxtelecom.com/ +44 (0)845 6667778 

Technical support    <[EMAIL PROTECTED]> 
Index: DriverManagerConnectionFactory.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/DriverManagerConnectionFactory.java,v
retrieving revision 1.8
diff -u -r1.8 DriverManagerConnectionFactory.java
--- DriverManagerConnectionFactory.java 28 Feb 2004 12:18:17 -0000      1.8
+++ DriverManagerConnectionFactory.java 23 Jun 2004 17:12:31 -0000
@@ -25,6 +25,7 @@
  *
  * @author Rodney Waldhoff
  * @author Ignacio J. Ortega
+ * @author Max Grender-Jones
  * @version $Revision: 1.8 $ $Date: 2004/02/28 12:18:17 $
  */
 public class DriverManagerConnectionFactory implements ConnectionFactory {
@@ -42,7 +43,7 @@
 
     public Connection createConnection() throws SQLException {
         if(null == _props) {
-            if((_uname == null) || (_passwd == null)) {
+            if((_uname == null) && (_passwd == null)) {
                 return DriverManager.getConnection(_connectUri);
             } else {
                 return DriverManager.getConnection(_connectUri,_uname,_passwd);

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to