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/22 23:37:19 UTC

Patch for DBConnection (sans turbine.jar)

I have a patch so that you don't need to include both
the turbine.jar and velocity.jar files when using
the Connection Pool by itself.  The problem is that the
DBFactory has a static initializer that reads in values
from the TR (the db adaptor).

But before I commit the fix, I want to be sure that how I am
using the pool (sans turbine) is correct:

   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 following will only run if both turbine and velocity jar
  files are in the CLASSPATH.

  However with my change, all you need to do is set the adaptor
      pool.setAdaptor("DBPostgres");

  before you call getConnection();

  then all you need is turbine-pool.jar.


  mike



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