commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1175267 - /commons/proper/dbutils/trunk/src/main/java/org/apache/commons/dbutils/DbUtils.java
Date Sat, 24 Sep 2011 21:25:32 GMT
Author: simonetripodi
Date: Sat Sep 24 21:25:32 2011
New Revision: 1175267

URL: http://svn.apache.org/viewvc?rev=1175267&view=rev
Log:
[DBUTILS-81] DbUtils.loadDriver() uses Class.forName()

Modified:
    commons/proper/dbutils/trunk/src/main/java/org/apache/commons/dbutils/DbUtils.java

Modified: commons/proper/dbutils/trunk/src/main/java/org/apache/commons/dbutils/DbUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/dbutils/trunk/src/main/java/org/apache/commons/dbutils/DbUtils.java?rev=1175267&r1=1175266&r2=1175267&view=diff
==============================================================================
--- commons/proper/dbutils/trunk/src/main/java/org/apache/commons/dbutils/DbUtils.java (original)
+++ commons/proper/dbutils/trunk/src/main/java/org/apache/commons/dbutils/DbUtils.java Sat
Sep 24 21:25:32 2011
@@ -176,8 +176,21 @@ public final class DbUtils {
      * @return boolean <code>true</code> if the driver was found, otherwise <code>false</code>
      */
     public static boolean loadDriver(String driverClassName) {
+        return loadDriver(DbUtils.class.getClassLoader(), driverClassName);
+    }
+
+    /**
+     * Loads and registers a database driver class.
+     * If this succeeds, it returns true, else it returns false.
+     *
+     * @param classLoader the class loader used to load the driver class
+     * @param driverClassName of driver to load
+     * @return boolean <code>true</code> if the driver was found, otherwise <code>false</code>
+     * @since 1.4
+     */
+    public static boolean loadDriver(ClassLoader classLoader, String driverClassName) {
         try {
-            Class.forName(driverClassName).newInstance();
+            classLoader.loadClass(driverClassName).newInstance();
             return true;
 
         } catch (IllegalAccessException e) {



Mime
View raw message