You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by Mike Haberman <mi...@ncsa.uiuc.edu> on 2001/03/23 00:05:18 UTC

Patch for using DBConnection without turbine.jar

I think i mailed this to working-dogs.  sorry :(


I have a patch so that you don't need to include both turbine.jar
and velocity.jar if you are using the connection pool sans turbine.

The problem lies in the DBFactory which has a static initializer
that loads adaptors/drivers from the TR.

But before I commit the fix, I want to be sure that I am using
the pool correctly:

   try 
   {
      ConnectionPool pool;
      DBConnection db;

      pool = new ConnectionPool(JDBC_DRIVER, url, "mikeh", "");
      db = pool.getConnection();

      String sql = "SELECT name from asset";
      Statement stmt  = db.createStatement();
      ResultSet rs    = stmt.executeQuery(sql);
      while(rs.next()) {
         System.out.println(rs.getString(1));
      }
      stmt.close();
      rs.close();

      pool.releaseConnection(db);
   }
   catch (Exception e)
   {
      e.printStackTrace();
   }


The above won't run unless both velocity.jar and turbine.jar are in
the classpath and you have init the TurbineConfig.

   The fix is to add the ability to set the adaptor:
   pool.setAdaptor("DBPostgres");
   before you call pool.getConnection();

   Then you can run your app with only turbine-pool.jar in your
   classpath.


mike

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org


Re: Patch for using DBConnection without turbine.jar

Posted by John McNally <jm...@collab.net>.
I believe Jason is working on a more general location for the
Configurations class.  turbine-pool should not require turbine.jar it
should just include the correct subset of files to get the pool working.

John McNally


Mike Haberman wrote:
> 
> I think i mailed this to working-dogs.  sorry :(
> 
> I have a patch so that you don't need to include both turbine.jar
> and velocity.jar if you are using the connection pool sans turbine.
> 
> The problem lies in the DBFactory which has a static initializer
> that loads adaptors/drivers from the TR.
> 
> But before I commit the fix, I want to be sure that I am using
> the pool correctly:
> 
>    try
>    {
>       ConnectionPool pool;
>       DBConnection db;
> 
>       pool = new ConnectionPool(JDBC_DRIVER, url, "mikeh", "");
>       db = pool.getConnection();
> 
>       String sql = "SELECT name from asset";
>       Statement stmt  = db.createStatement();
>       ResultSet rs    = stmt.executeQuery(sql);
>       while(rs.next()) {
>          System.out.println(rs.getString(1));
>       }
>       stmt.close();
>       rs.close();
> 
>       pool.releaseConnection(db);
>    }
>    catch (Exception e)
>    {
>       e.printStackTrace();
>    }
> 
> The above won't run unless both velocity.jar and turbine.jar are in
> the classpath and you have init the TurbineConfig.
> 
>    The fix is to add the ability to set the adaptor:
>    pool.setAdaptor("DBPostgres");
>    before you call pool.getConnection();
> 
>    Then you can run your app with only turbine-pool.jar in your
>    classpath.
> 
> mike
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org