Hack to force classloader t find mariadb driver 39/77739/1
authorTimoney, Dan (dt5972) <dtimoney@att.com>
Fri, 1 Feb 2019 20:45:52 +0000 (15:45 -0500)
committerTimoney, Dan (dt5972) <dtimoney@att.com>
Fri, 1 Feb 2019 20:45:52 +0000 (15:45 -0500)
Container is not coming up because dblib is getting
ClassNotFoundException for mariadb driver, even though
it is installed.  To correct this temporarily, updated
code to explicitly create a driver object.

Change-Id: I210d042be2c71a4392781ad26f858c916dbd7364
Issue-ID: CCSDK-489
Signed-off-by: Timoney, Dan (dt5972) <dtimoney@att.com>
dblib/provider/src/main/java/org/onap/ccsdk/sli/core/dblib/DBResourceManager.java

index 9d797d0..0b8c565 100755 (executable)
@@ -24,6 +24,7 @@ package org.onap.ccsdk.sli.core.dblib;
 
 import java.io.PrintWriter;
 import java.sql.Connection;
+import java.sql.Driver;
 import java.sql.SQLDataException;
 import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
@@ -92,6 +93,12 @@ public class DBResourceManager implements DataSource, DataAccessor, DBResourceOb
 
     public DBResourceManager(final Properties properties) {
         this.configProps = properties;
+        
+        // TODO : hack to force classloader to cache mariadb driver.  This shouldnt be necessary,
+        // but for some reason it is (without this, dblib throws ClassNotFound on mariadb driver
+        // and fails to load).
+        Driver dvr = new org.mariadb.jdbc.Driver();
+        dvr = null;
 
         // get retry interval value
         retryInterval = getLongFromProperties(properties, "org.onap.dblib.connection.retry", 10000L);