I applied this patch though I changed it to only complain if driver or
url are not set.  I know that password is not always required and it is
possible that some might not require a username.

john mcnally

On Tue, 2002-04-16 at 06:24, Bill Schneider wrote:
> if you make the mistake of making your Torque.properties look like
> 
> torque.database.default=MY-DATABASE
> torque.database.default.url=... # should be torque.database.MY-DATABASE.url
> etc.
> 
> then you get an unhelpful error "Connection object was null" error message.
> This patch makes the error much more explicit.
> 
> -- Bill
> 
> Index: src/java/org/apache/torque/Torque.java
> ===================================================================
> RCS file:
> /home/cvspublic/jakarta-turbine-torque/src/java/org/apache/torque/Torque.jav
> a,v
> retrieving revision 1.51
> diff -u -r1.51 Torque.java
> --- src/java/org/apache/torque/Torque.java 27 Mar 2002 23:41:32 -0000 1.51
> +++ src/java/org/apache/torque/Torque.java 16 Apr 2002 13:22:02 -0000
> @@ -1001,13 +1001,25 @@
>          // If the pool is not in the Hashtable, we must register it.
>          if ( pool == null )
>          {
> -            registerPool(
> -                name,
> -                getDatabaseProperty(name, "driver"),
> -                getDatabaseProperty(name, "url"),
> -                getDatabaseProperty(name, "username"),
> -                getDatabaseProperty(name, "password"));
> +            // check that pool for this particular db is actually
> +            // configured
> 
> +            String driver = getDatabaseProperty(name, "driver");
> +            String url = getDatabaseProperty(name, "url");
> +            String username = getDatabaseProperty(name, "username");
> +            String password = getDatabaseProperty(name, "password");
> +
> +            if (driver == null || url == null
> +                  || username == null || password == null
> +                  || driver.equals("") || url.equals("")
> +                  || username.equals("") || password.equals(""))
> +            {
> +                throw new TorqueException
> +                    ("Attempt to register pool for database " + name
> +                       + " that is not configured in Torque.properties");
> +            }
> +
> +            registerPool(name, driver, url, username, password);
>              pool = (ConnectionPool) pools.get(name);
>          }
> 
> 
> 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 



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

Reply via email to