You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by fh...@apache.org on 2008/11/26 00:37:00 UTC

svn commit: r720668 - in /tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool: DataSourceProxy.java Driver.java

Author: fhanik
Date: Tue Nov 25 15:37:00 2008
New Revision: 720668

URL: http://svn.apache.org/viewvc?rev=720668&view=rev
Log:
Remove the Driver class, its not used anymore, and if it was used, there needs to be a way to instantiate from a properties file or similar



Removed:
    tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/Driver.java
Modified:
    tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java

Modified: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java?rev=720668&r1=720667&r2=720668&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java (original)
+++ tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java Tue Nov 25 15:37:00 2008
@@ -41,7 +41,7 @@
 public class DataSourceProxy  {
     protected static Log log = LogFactory.getLog(DataSourceProxy.class);
     
-    protected Driver driver;
+    protected volatile ConnectionPool pool = null;
     protected PoolProperties poolProperties = new PoolProperties();
 
     public DataSourceProxy() {
@@ -75,12 +75,12 @@
      * @return Driver
      * @throws SQLException
      */
-    public synchronized Driver createDriver() throws SQLException {
-        if (driver != null) {
-            return driver;
+    public synchronized ConnectionPool createPool() throws SQLException {
+        if (pool != null) {
+            return pool;
         } else {
-            driver = new org.apache.tomcat.jdbc.pool.Driver(getPoolProperties());
-            return driver;
+            pool = new ConnectionPool(poolProperties);
+            return pool;
         }
     }
 
@@ -89,9 +89,9 @@
      */
 
     public Connection getConnection() throws SQLException {
-        if (driver == null)
-            driver = createDriver();
-        return driver.connect(poolProperties.getPoolName(), null);
+        if (pool == null)
+            return createPool().getConnection();
+        return pool.getConnection();
     }
 
     /**
@@ -151,10 +151,10 @@
     }
     public void close(boolean all) {
         try {
-            if (driver != null) {
-                Driver d = driver;
-                driver = null;
-                d.closePool(poolProperties.getPoolName(), all);
+            if (pool != null) {
+                final ConnectionPool p = pool;
+                pool = null;
+                if (p!=null) p.close(all);
             }
         }catch (Exception x) {
             x.printStackTrace();
@@ -167,9 +167,9 @@
     }
 
     public int getPoolSize() throws SQLException{
-        if (driver == null)
-            driver = createDriver();
-        return driver.getPool(getPoolProperties().getPoolName()).getSize();
+        final ConnectionPool p = pool;
+        if (p == null) return 0;
+        else return p.getSize();
     }
 
     public String toString() {



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