db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1839179 - /db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/AdapterFactory.java
Date Sun, 26 Aug 2018 09:49:06 GMT
Author: tv
Date: Sun Aug 26 09:49:06 2018
New Revision: 1839179

URL: http://svn.apache.org/viewvc?rev=1839179&view=rev
Log:
Add new MySQL driver class name

Modified:
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/AdapterFactory.java

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/AdapterFactory.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/AdapterFactory.java?rev=1839179&r1=1839178&r2=1839179&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/AdapterFactory.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/AdapterFactory.java
Sun Aug 26 09:49:06 2018
@@ -62,6 +62,7 @@ public final class AdapterFactory
             MssqlAdapter.class);
         adapters.put("com.jnetdirect.jsql.JSQLDriver", MssqlAdapter.class);
         adapters.put("org.gjt.mm.mysql.Driver", MysqlAdapter.class);
+        adapters.put("com.mysql.cj.jdbc.Driver", MysqlAdapter.class);
         adapters.put("oracle.jdbc.driver.OracleDriver", OracleAdapter.class);
         adapters.put("org.postgresql.Driver", PostgresAdapter.class);
 
@@ -114,27 +115,16 @@ public final class AdapterFactory
         DatabaseMetaData dmd = con.getMetaData();
         String dbmsName = dmd.getDatabaseProductName();
 
-        Class<? extends Adapter> adapterClass = adapters.get(dbmsName);
+        Adapter adapter = create(dbmsName);
 
-        if (adapterClass == null)
+        if (adapter == null)
         {
             throw new InstantiationException("Could not detect adapter for database: " +
dbmsName);
         }
 
-        log.info("Mapped database product " + dbmsName + " to adapter " + adapterClass.getSimpleName());
+        log.info("Mapped database product " + dbmsName + " to adapter " + adapter.getClass().getSimpleName());
 
-        try
-        {
-            Adapter adapter = adapterClass.newInstance();
-            return adapter;
-        }
-        catch (IllegalAccessException e)
-        {
-            throw new InstantiationException(
-                "Could not instantiate adapter for database: "
-                + dbmsName
-                + ": Assure that adapter classes are in your classpath");
-        }
+        return adapter;
     }
 
     /**
@@ -203,18 +193,9 @@ public final class AdapterFactory
                     + ": Check your configuration file");
         }
 
-        try
-        {
-            Adapter adapter = (Adapter) adapterClass.newInstance();
-            adapters.put(key, (Class<? extends Adapter>) adapterClass);
-            return adapter;
-        }
-        catch (IllegalAccessException e)
-        {
-            throw new InstantiationException(
-                "Could not instantiate adapter for key: "
-                + key
-                + ": Assure that adapter classes are in your classpath");
-        }
+        adapters.put(key, (Class<? extends Adapter>) adapterClass);
+        Adapter adapter = create(key);
+
+        return adapter;
     }
 }



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


Mime
View raw message