added file extension php5
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.quantum.sql / src / com / quantum / util / JarUtil.java
index c30bdad..2519891 100644 (file)
@@ -24,23 +24,36 @@ public class JarUtil {
        public static Driver loadDriver(String driverFile, String className) {
                Driver result = null;
                try {
-               File file = new File(driverFile);
-               if (file.exists() && file.isFile()) {
-                       URLClassLoader loader = getURLClassLoader(file);
-                       Class driverClass = loader.loadClass(className);
+                       Class driverClass = loadDriverClass(driverFile, className);
+                       if (driverClass != null) {
                    try {
                        result = (Driver) driverClass.newInstance();
                    } catch (ClassCastException e) {
                    }
                }
-               } catch (MalformedURLException e) {
-               } catch (ClassNotFoundException e) {
                } catch (InstantiationException e) {
                } catch (IllegalAccessException e) {
                }
                return result;
        }
        
+       public static Class loadDriverClass(String driverFile, String className) {
+               Class result = null;
+               if (driverFile != null && className != null) {
+                       try {
+                       File file = new File(driverFile);
+                       if (file.exists() && file.isFile()) {
+                               URLClassLoader loader = getURLClassLoader(file);
+                               Class driverClass = loader.loadClass(className);
+                               result = Driver.class.isAssignableFrom(driverClass) ? driverClass : null;
+                       }
+                       } catch (MalformedURLException e) {
+                       } catch (ClassNotFoundException e) {
+                       }
+               }
+               return result;
+       }
+       
        public static String[] getAllDriverNames(String driverFile) {
                List list = new ArrayList();
                try {