db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mpoes...@apache.org
Subject cvs commit: jakarta-turbine-torque/src/java/org/apache/torque Torque.java
Date Sat, 14 Dec 2002 14:33:13 GMT
mpoeschl    2002/12/14 06:33:13

  Modified:    src/java/org/apache/torque Torque.java
  Log:
  readd getConnection(String name, String username, String password)
  
  Revision  Changes    Path
  1.75      +40 -1     jakarta-turbine-torque/src/java/org/apache/torque/Torque.java
  
  Index: Torque.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-torque/src/java/org/apache/torque/Torque.java,v
  retrieving revision 1.74
  retrieving revision 1.75
  diff -u -r1.74 -r1.75
  --- Torque.java	11 Dec 2002 18:02:12 -0000	1.74
  +++ Torque.java	14 Dec 2002 14:33:13 -0000	1.75
  @@ -905,6 +905,45 @@
       }
   
       /**
  +     * This method returns a Connecton using the given parameters.
  +     * You should only use this method if you need user based access to the
  +     * database!
  +     *
  +     * @param name The database name.
  +     * @param username The name of the database user.
  +     * @param password The password of the database user.
  +     * @return A Connection.
  +     * @throws TorqueException Any exceptions caught during processing will be
  +     *         rethrown wrapped into a TorqueException.
  +     */
  +    public static Connection getConnection(String name, String username,
  +            String password)
  +            throws TorqueException
  +    {
  +        Connection con = null;
  +        DataSourceFactory dsf = null;
  +        try
  +        {
  +            dsf = (DataSourceFactory) dsFactoryMap.get(name);
  +            con = dsf.getDataSource().getConnection(username, password);
  +        }
  +        catch (Exception e)
  +        {
  +             if (dsf == null && e instanceof NullPointerException)
  +             {
  +                 throw new NullPointerException(
  +                         "There was no DataSourceFactory "
  +                         + "configured for the connection " + name);
  +             }
  +             else
  +             {
  +                 throw new TorqueException(e);
  +             }
  +        }
  +        return con;
  +    }
  +
  +    /**
        * Returns database adapter for a specific connection pool.
        *
        * @param name A pool name.
  
  
  

Mime
View raw message