Skip to content

Apache Lucene open-source search software

SOLR-1450 -- Jdbc connection properties such as batchSize are not applied if the driver jar is placed in solr_home/lib

Shalin Shekhar Mangar2d7502ecf446
diff --git a/contrib/dataimporthandler/CHANGES.txt b/contrib/dataimporthandler/CHANGES.txt
index 3c6bc653775..7641a5ab9cf 100644
--- a/contrib/dataimporthandler/CHANGES.txt
+++ b/contrib/dataimporthandler/CHANGES.txt
@@ -258,6 +258,10 @@ Bug Fixes
(Jay Hill, Noble Paul via ehatcher)
29.SOLR-1323: Reset XPathEntityProcessor's $hasMore/$nextUrl when fetching next URL (noble, ehatcher)
+
+30.SOLR-1450: Jdbc connection properties such as batchSize are not applied if the driver jar is placed
+ in solr_home/lib.
+ (Steve Sun via shalin)
Documentation
diff --git a/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/JdbcDataSource.java b/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/JdbcDataSource.java
index 0b749acd185..83b6a824a42 100644
--- a/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/JdbcDataSource.java
+++ b/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/JdbcDataSource.java
@@ -153,6 +153,15 @@ public class JdbcDataSource extends
"the jndi name : '"+jndiName +"' is not a valid javax.sql.DataSource");
}
}
+ } catch (SQLException e) {
+ // DriverManager does not allow you to use a driver which is not loaded through
+ // the class loader of the class which is trying to make the connection.
+ // This is a workaround for cases where the user puts the driver jar in the
+ // solr.home/lib or solr.home/core/lib directories.
+ Driver d = (Driver) DocBuilder.loadClass(driver, context.getSolrCore()).newInstance();
+ c = d.connect(url, initProps);
+ }
+ if (c != null) {
if (Boolean.parseBoolean(initProps.getProperty("readOnly"))) {
c.setReadOnly(true);
// Add other sane defaults
@@ -181,13 +190,6 @@ public class JdbcDataSource extends
} else {
c.setHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT);
}
- } catch (SQLException e) {
- // DriverManager does not allow you to use a driver which is not loaded through
- // the class loader of the class which is trying to make the connection.
- // This is a workaround for cases where the user puts the driver jar in the
- // solr.home/lib or solr.home/core/lib directories.
- Driver d = (Driver) DocBuilder.loadClass(driver, context.getSolrCore()).newInstance();
- c = d.connect(url, initProps);
}
LOG.info("Time taken for getConnection(): "
+ (System.currentTimeMillis() - start));