Skip to content

Commit

Permalink
[SPARK-6966][SQL] Use correct ClassLoader for JDBC Driver
Browse files Browse the repository at this point in the history
Otherwise we cannot add jars with drivers after the fact.

Author: Michael Armbrust <michael@databricks.com>

Closes #5543 from marmbrus/jdbcClassloader and squashes the following commits:

d9930f3 [Michael Armbrust] fix imports
73d0614 [Michael Armbrust] [SPARK-6966][SQL] Use correct ClassLoader for JDBC Driver
  • Loading branch information
marmbrus committed Apr 17, 2015
1 parent 1e43851 commit e5949c2
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.apache.spark.sql.SQLContext
import org.apache.spark.sql.catalyst.expressions.Row
import org.apache.spark.sql.sources._
import org.apache.spark.sql.types.StructType
import org.apache.spark.util.Utils

/**
* Data corresponding to one partition of a JDBCRDD.
Expand Down Expand Up @@ -99,7 +100,7 @@ private[sql] class DefaultSource extends RelationProvider {
val upperBound = parameters.getOrElse("upperBound", null)
val numPartitions = parameters.getOrElse("numPartitions", null)

if (driver != null) Class.forName(driver)
if (driver != null) Utils.getContextOrSparkClassLoader.loadClass(driver)

if (partitionColumn != null
&& (lowerBound == null || upperBound == null || numPartitions == null)) {
Expand Down

0 comments on commit e5949c2

Please sign in to comment.